QAction Disabled Problem
Unsolved
General and Desktop
-
I would like to disable an action with an ask, in a slot
void CMainWindow::warnDisableMyAct()//this is a slot { QMessageBox::StandardButton ans = QMessageBox::question(this, tr("close tips"),tr("Are you sure to close this function?")); bool isClose = (ans == QMessageBox::Yes); myAct->setDisabled(isClosed); //bool isEnabled=myAct->isEnabled(); }
when I choose Yes in message box ,isEnabled is false ,but the relevent toolbar and menu is still visible and can be clicked. I try to call repaint(),update() of this window,but nothing different happend. And if I don't ask any more,myAct can be disabled,
void CMainWindow::warnDisableMyAct()//this is a slot { myAct->setDisabled(true); }
It seems that setDisabled can't be called in selective structure and it's parameter must be a definitized value. Is anyone meet this situation?
-
-
Yes, I post a wrong code, the right code is
void CMainWindow::warnDisableMyAct()//this is a slot { QMessageBox::StandardButton ans = QMessageBox::question(this, tr("close tips"),tr("Are you sure to close this function?")); bool isClose = (ans == QMessageBox::Yes); myAct->setDisabled(isClose); //bool isEnabled=myAct->isEnabled(); }
and the comment code here is just for debug, it doesn't matter if it is called.