The pushButton isn't staying checked while the menu is up.
I was not aware you were popping a menu as a reaction to a toggle button.
the button changes to checked(false)... even though the menu is still up.
That is because the QAction object is still doing its work, and the button is connected to it.
They both don't know you are "cheating" with the menu. (making it behave in a way not consistent with what the QAction scheme is design to do)
In your case I would reconsider using QAction, and just make your own signal slot connections.
QAction and other such mini frameworks are designed to make life easier for common coding tasks, but if you want something different, then you might be better of doing things your own way.
Any how, how about the following:
//somewhere:
connect(myButton,SIGNAL(toggled(bool)),this,SLOT(checkMenuState(bool)));
void Window::checkMenuState(bool checked)
{
if(myMenu->isUnderMouse() && !checked)
{
myButton->setChecked(true);
{
}
//somewhere:
connect(myButton,SIGNAL(toggled(bool)),this,SLOT(checkMenuState(bool)));
void Window::checkMenuState(bool checked)
{
if(myMenu->isUnderMouse() && !checked)
{
myButton->setChecked(true);
{
}
To copy to clipboard, switch view to plain text mode
It could be that you will have also have to take care of the un-checking your self when the menu closes.
Bookmarks