Hi,

I am having issues with using Qt::UserRole with Qtreewidgetitem.

Here's my code :

Qt Code:
  1. UGS::AsciiString Hdrstr = "Header";
  2. QString str = QString::fromUtf8(Hdrstr.c_str());
  3. QVariant Headerqv(str);
  4.  
  5. RootWidget->setData(0, Qt::UserRole + 1, Headerqv);
To copy to clipboard, switch view to plain text mode 

And finally retrieving the value:

Qt Code:
  1. StrValue = Widgetitem->data(0, Qt::UserRole + 1);
  2. QString strval = StrValue.toString();
  3.  
  4. 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 !