Would this look simpler
Qt Code:
  1. ...
  2. ...
  3. const A a0;
  4. ...
  5. item.setData(reinterpret_cast<unsigned int>(&a), Role);
  6. ...
  7. const A & a1 = *reinterpret_cast<const A*>(item.data(Role).toUInt());
  8. //or
  9. const A & a2 = *reinterpret_cast<const A*>(modelIndex.data(Role).toUInt());
  10. ...
To copy to clipboard, switch view to plain text mode