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.

Qt Code:
  1. QTreeWidgetItem *itemdist = new QTreeWidgetItem();
  2. District *dist;
  3. itemdist->setData(1, Qt::ToolTipRole, dist);
  4. QVariant item = itemdist->data(1, Qt::ToolTipRole);
  5. district *temp = static_cast<district*>(temp1);
To copy to clipboard, switch view to plain text mode 

But in line 5 it is showing error as

Qt Code:
  1. error C2440: 'static_cast' : cannot convert from 'QVariant' to 'district *'
To copy to clipboard, switch view to plain text mode 

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.