If it is not the same pointer, how can it be the same object?
Well I needed 2 pointers to point to the same address. So it's the same object coz they are pointing to the same value. I think that's what you wanted to say.
But anyhow, I got the solution. I was just writing some extra lines of code for no reason. I did the following :
RootWidget->setData(0, Qt::UserRole, Headerqv);
QVariant StrValue
= RootWidget
->data
(0, Qt
::UserRole);
QString strval
= StrValue.
toString();
string str = strval.toStdString();
QVariant Headerqv = QVariant("Header");
RootWidget->setData(0, Qt::UserRole, Headerqv);
QVariant StrValue = RootWidget->data(0, Qt::UserRole);
QString strval = StrValue.toString();
string str = strval.toStdString();
To copy to clipboard, switch view to plain text mode
But thanks for all the help 
Regards,
Bookmarks