[Solved] Losing Menubar Shortcuts after executing QDialog corresponding to loss of ActiveWindow [by updating from 5.0.1 to 5.2.1]



  • Dear all,

    Since changing from Qt4 to Qt5 the shortcuts of my MainWindow menubar did only work on some kind of a random basis. Looking into the problem revealed, that they stop working after calling a(ny) QDialog with exec(). The shortcuts resumed work after (mouse)clicking on the menubar.

    I can see that keystrokes of the shortcuts are passed through the keyEventPressed of my MainWindow at any time, but they only work when QApplication::activeWindow() returns a valid pointer (to the MainWindow).

    So my quick and dirty fix was to put "QApplication::setActiveWindow( this );" into MainWindow::keyPressEvent. This kind of resurrects the shortcuts, when they are pressed once or twice, but this is rather ugly.

    Therefore I would like to know, how to fix this issue properly?


  • Lifetime Qt Champion

    Hi and welcome to devnet,

    Can you also post which OS you are running on and the exact Qt version ?



  • Qt 5.0.1 as provided with Ubuntu 13.10.


  • Lifetime Qt Champion

    You should consider using the latest version, currently 5.2.1, there's been a lot of bug fixes done since 5.0.1



  • Installing and compiling with 5.2.1 did solve the problem of loosing focus – thanks for the advice! I really did not expect 5.0.1 to be so buggy.

    However, the look of the menubar has changed. Before it behaved like any other menu and was moved to the top bar of the Unity desktop - identical to many other applications. After the upgrade the menubar stays below the top bar of the application's windows like in traditional window managers. Therefore I am curious how to change this behavior?


  • Lifetime Qt Champion

    That would be more a question for the Ubuntu's developers. IIRC they have patched Qt to make it work with Unity. These might be available through their servers


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.