0

If I put a class with a destructor in a QVariant, will the QVariant's destruction call the proper destructor of the non-POD class it contains?

Here's an example, where I'm putting a class into a QVariant owned by a QWidget:

QVariant variant = QVariant::fromValue(MyObject());
widget->setProperty("ui", variant);

My expectation is that the lifetime of the dynamic variable I care about (MyObject) will last until the QWidget is destroyed, and at that time, MyObject will be properly destructed with a call the it's destructor. (i.e. ~QWidget() -> ~QVariant() -> ~MyObject())

Jamin Grey
  • 10,151
  • 6
  • 39
  • 52

0 Answers0