Buttons in layout enabled but not accessible.
-
@SPlatten
Continue back up the hierarchy ofQWidgetparents. I believe you will find one of them is disabled, and this results in descendants being disabled even if their ownisEnabled()returns true?@JonB, I've tried the following:
QHBoxLayout* pobjHBox(qobject_cast<QHBoxLayout*>(mpobjLO)); if ( pobjHBox != nullptr ) { pobjHBox->addWidget(pobjButton); bool blnEnabled(pobjButton->isEnabled()), blnLOEnabled(pobjHBox->isEnabled()); qdbg() << blnEnabled << blnLOEnabled;mpobjLO is the layout containing the buttons, the layout containing this layout is most definitely enabled and other controls within the form are selectable and editable.
The button is enabled, so is the layout, but the buttons appear greyed and I cannot click on them.
-
@JonB, I've tried the following:
QHBoxLayout* pobjHBox(qobject_cast<QHBoxLayout*>(mpobjLO)); if ( pobjHBox != nullptr ) { pobjHBox->addWidget(pobjButton); bool blnEnabled(pobjButton->isEnabled()), blnLOEnabled(pobjHBox->isEnabled()); qdbg() << blnEnabled << blnLOEnabled;mpobjLO is the layout containing the buttons, the layout containing this layout is most definitely enabled and other controls within the form are selectable and editable.
The button is enabled, so is the layout, but the buttons appear greyed and I cannot click on them.
-
qdbg() << "HACK: " << pobjButton->isEnabled() << " " << pobjButton->parentWidget()->isEnabled() << " " << pobjButton->parentWidget()->parentWidget()->isEnabled() ;I added "HACK:" so I can search the Application Output , the result is:
S000000000068E000000161861T16:09:33.535DL00000139F../clsQtLayout.cpp[void clsQtLayout::addButton] HACK: true true true S000000000069E000000164553T16:09:36.227D:HACK: true true true S000000000070E000000165670T16:09:37.344D:HACK: true true true3 times because there are 3 buttons I the layout.
-
add the following in this class
protected:
virtual void showEvent( QShowEvent * ) override;add your following code inside showEvent( )
qdbg() << "HACK: " << pobjButton->isEnabled() << " " << pobjButton->parentWidget()->isEnabled() << " " << pobjButton->parentWidget()->parentWidget()->isEnabled() ;this will tell you if they are enabled or not when they are displayed.
-
add the following in this class
protected:
virtual void showEvent( QShowEvent * ) override;add your following code inside showEvent( )
qdbg() << "HACK: " << pobjButton->isEnabled() << " " << pobjButton->parentWidget()->isEnabled() << " " << pobjButton->parentWidget()->parentWidget()->isEnabled() ;this will tell you if they are enabled or not when they are displayed.
@JoeCFD said in Buttons in layout enabled but not accessible.:
virtual void showEvent( QShowEvent * ) override;
The trouble is I've done something very clever or very stupid, several months ago and now I'm trying to revisit it and see what I've done, if I add another button which has different properties it works fine, so this is NOT a Qt issue.
-
@JoeCFD said in Buttons in layout enabled but not accessible.:
virtual void showEvent( QShowEvent * ) override;
The trouble is I've done something very clever or very stupid, several months ago and now I'm trying to revisit it and see what I've done, if I add another button which has different properties it works fine, so this is NOT a Qt issue.
-
@SPlatten showEvent( QShowEvent * ) is the final spot to check if they are enabled or not. It is a good place for layout debugging. After debugging, simply remove it.