sudheer168
2nd November 2009, 05:27
Hi everybody ,
I got problem regarding typecasting . I have one structure called Disrict and I want to set the object of district as data to Qtreewidgetitem.
QTreeWidgetItem *itemdist = new QTreeWidgetItem();
District *dist;
itemdist->setData(1, Qt::ToolTipRole, dist);
QVariant item = itemdist->data(1, Qt::ToolTipRole);
district *temp = static_cast<district*>(temp1);
But in line 5 it is showing error as
error C2440: 'static_cast' : cannot convert from 'QVariant' to 'district *'
I tried by using reinterpret_cast ,but it is showing same error . so how can I cast the variant item to district type. The main thing I want to do is assing district object to Qtreewidgetitem object and I want to get back the district object using Qtreewidgetitem object.
So please suggest me to solve this problem.
Regards,
Sudheer.
I got problem regarding typecasting . I have one structure called Disrict and I want to set the object of district as data to Qtreewidgetitem.
QTreeWidgetItem *itemdist = new QTreeWidgetItem();
District *dist;
itemdist->setData(1, Qt::ToolTipRole, dist);
QVariant item = itemdist->data(1, Qt::ToolTipRole);
district *temp = static_cast<district*>(temp1);
But in line 5 it is showing error as
error C2440: 'static_cast' : cannot convert from 'QVariant' to 'district *'
I tried by using reinterpret_cast ,but it is showing same error . so how can I cast the variant item to district type. The main thing I want to do is assing district object to Qtreewidgetitem object and I want to get back the district object using Qtreewidgetitem object.
So please suggest me to solve this problem.
Regards,
Sudheer.