PDA

View Full Version : Does QWidget::setAttribute() work with QWidget child classes?



Wasabi
16th September 2010, 16:47
This is a purely theoretical question, no actual code to display (well, one line). If I create a class that inherits from QWidget, does .setAttribute() still work for it? Most importantly, does it work with WA_DeleteOnClose?



//...
(myWidget) potato;
potato.setAttribute(Qt::WA_DeleteOnClose);
//....

Will WA_DeleteOnClose summon the class' destructor or only QWidget's?

Lykurg
16th September 2010, 16:57
this is a question you can answer yourself. Simply create a subclass and see if the d-tor is called:
class MyWidget : public QWidget
{
Q_OBJECT

public:
MyWidget(QWidget* parent = 0) : QWidget(parent) { setAttribute(Qt::WA_DeleteOnClose); }
~MyWidget() { qDebug() << Q_FUNC_INFO; }
}
and now see the output and your question answered.