PDA

View Full Version : QPushButton::setEnabled( true ) not working



unshaven
8th August 2012, 17:17
Hallo,

on a MainForm, I stacked a few widgets (in designer, partially overlapping, some visible by default, some not).
I have a QWidget ontop of some other things, which has three buttons on it, and a QLineEdit above them.

Those buttons are already set disabled (enabled not checked) by QtCreator designer once in a while, even if I set them to enabled again.
The widget is invisible normally, only sometimes I make it visible to show the buttons & lineedit.
Now, in the code, before using the buttons, I set everything enabled explcitly, to make sure.
But it doesn't work, and the assert at the end fails:



ui->widgetPanel->setEnabled( true );

ui->btnNo->setEnabled( true );
ui->btnYes->setEnabled( true );

ui->widgetPanel->show();


Q_ASSERT( ui->btnNo->isEnabled() );


What could be the cause of this? Does Qt have problems with layers of widgets, even if some are invisible?
It was working for a while, though, and I was changing sizes and moving widgets around, then it stopped.
(and I did check in the "widget tree" that everything is correct in the hierarchy)

myta212
9th August 2012, 06:27
Hi,
Qt dont have a problem about layering.
I think you call "enabled button" at the wrong position. So, the enable button not changed.
Can you share your complete code, so we can check that.

Best regards,

myta