Results 1 to 3 of 3

Thread: QMenu still highligheted after action fired in mac

  1. #1
    Join Date
    Jul 2008
    Posts
    3
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Question QMenu still highligheted after action fired in mac

    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.
    Qt Code:
    1. void WaveView::changeVelocity()
    2. {
    3. if (!inputStrip)
    4. return;
    5. ChangeVelocity *cv = new ChangeVelocity(&currentEvents, inputStrip);
    6. connect(cv, SIGNAL(changed()), this, SLOT(update()));
    7. bool res= cv->exec();
    8. delete cv;
    9. if (res ==false) {
    10. /* Don't do stuff */
    11. } else {
    12. /* Do Stuff*/
    13. }
    14. }
    15. }
    To copy to clipboard, switch view to plain text mode 
    If i change the code to not show the dialog, like below, the problem dosen't appear any longer..
    Qt Code:
    1. void WaveView::changeVelocity()
    2. {
    3. if (!inputStrip)
    4. return;
    5. bool res = false;
    6. if (res ==false) {
    7. /* Don't do stuff */
    8. } else {
    9. /* Do Stuff*/
    10. }
    11. }
    12. }
    To copy to clipboard, switch view to plain text mode 

    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!

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QMenu still highligheted after action fired in mac

    The behaviour is logical. If you want to achieve the effect you want, change your code like so:

    Qt Code:
    1. ChangeVelocity *cv = new ChangeVelocity(&currentEvents, inputStrip);
    2. connect(cv, SIGNAL(changed()), this, SLOT(update()));
    3. connect(cv, SIGNAL(accepted()), this, SLOT(onAccepted()));
    4. cv->setAttribute(Qt::WA_DeleteOnClose, true);
    5. QTimer::singleShot(0, cv, SLOT(exec()));
    6.  
    7. void XX::onAccepted(){
    8. // do stuff
    9. }
    To copy to clipboard, switch view to plain text mode 

  3. #3
    Join Date
    Jul 2008
    Posts
    3
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Thumbs up Re: QMenu still highligheted after action fired in mac

    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!

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.