Hi,
I am having issues with using Qt::UserRole with Qtreewidgetitem.
Here's my code :
UGS::AsciiString Hdrstr = "Header";
RootWidget->setData(0, Qt::UserRole + 1, Headerqv);
UGS::AsciiString Hdrstr = "Header";
QString str = QString::fromUtf8(Hdrstr.c_str());
QVariant Headerqv(str);
RootWidget->setData(0, Qt::UserRole + 1, Headerqv);
To copy to clipboard, switch view to plain text mode
And finally retrieving the value:
StrValue = Widgetitem->data(0, Qt::UserRole + 1);
QString strval
= StrValue.
toString();
if (strval.toStdString() == "Header")
StrValue = Widgetitem->data(0, Qt::UserRole + 1);
QString strval = StrValue.toString();
if (strval.toStdString() == "Header")
To copy to clipboard, switch view to plain text mode
In this line :
if (strval.toStdString() == "Header")
there's no value of the string. Can anyone suggest what am I doing wrong over here ?
Thank you !
Bookmarks