PDA

View Full Version : QMenu still highligheted after action fired in mac



berinder
23rd July 2008, 16:53
Hello,

In Mac OS X i'm having a problem with the QMenuBar.

I have a QAction that shows a QDialog, when the Dialog is closed the QMenu still is highlighted though.

If i remove the QDialog it works as suspected.

Is there some magic that must be done when closing a QDialog?

In short, this is what the slot looks lite that the QAction fires. If i return out in the sanity-check, it's ok. The menu returns to correct state.


void WaveView::changeVelocity()
{
if (!inputStrip)
return;
ChangeVelocity *cv = new ChangeVelocity(&currentEvents, inputStrip);
connect(cv, SIGNAL(changed()), this, SLOT(update()));
bool res= cv->exec();
delete cv;
if (res ==false) {
/* Don't do stuff */
} else {
/* Do Stuff*/
}
}
}

If i change the code to not show the dialog, like below, the problem dosen't appear any longer..


void WaveView::changeVelocity()
{
if (!inputStrip)
return;
bool res = false;
if (res ==false) {
/* Don't do stuff */
} else {
/* Do Stuff*/
}
}
}


Both the cancel and OK buttons are connected to reject and accept, and the Dialog is working as expected...

I'm using Qt 4.2.3 but have checked Recent Changes and found nothing about a fix for a bug like this. This leads me to believe that i'm doing something wrong instead of it being a bug in QT

Thanks in advance!

wysota
26th July 2008, 15:47
The behaviour is logical. If you want to achieve the effect you want, change your code like so:


ChangeVelocity *cv = new ChangeVelocity(&currentEvents, inputStrip);
connect(cv, SIGNAL(changed()), this, SLOT(update()));
connect(cv, SIGNAL(accepted()), this, SLOT(onAccepted()));
cv->setAttribute(Qt::WA_DeleteOnClose, true);
QTimer::singleShot(0, cv, SLOT(exec()));

void XX::onAccepted(){
// do stuff
}

berinder
1st September 2008, 20:53
Thanks for the help Wysota, copied your code directly in and it worked as a charm.

I've been frustrated over that bug for a long time and with your help my day got brighter.

Thans and a thumb up for you! :)