I've run into an odd problem when trying to disable a QAction menu item object. There's no good way to paste a small working example, but the code of note is as follows:
ui.button_send->setEnabled(true);
std::cout << ui.actionConnect->isEnabled() << std::endl;
ui.actionConnect->setEnabled(false);
std::cout << ui.actionConnect->isEnabled() << std::endl;
ui.button_send->setEnabled(true);
std::cout << ui.actionConnect->isEnabled() << std::endl;
ui.actionConnect->setEnabled(false);
std::cout << ui.actionConnect->isEnabled() << std::endl;
To copy to clipboard, switch view to plain text mode
I am trying to have a button that I can click to connect to a simulator (details not important). When the simulator boots up, it sends a signal back that calls the function with this code. The print lines read "1" then "0" as expected, indicating that the actionConnect menu item is no longer enabled. However, I can still click on the meny item after this occurs, and it triggers another redundant attempt to connect (i.e., it is not disabled at all). The button_send button in ui, however, does get enabled properly (after being disabled on startup).
I found a few places through online searching that indicate there may be bugs with QAction::setEnabled(), but nothing concrete. Is there anywhere else I should look to figure out what might be the problem? I know this is vague, so I'm mostly just looking for ideas or hints. Thanks in advance.
Bookmarks