Results 1 to 2 of 2

Thread: QMenu take Main Window focus

  1. #1
    Join Date
    Nov 2019
    Location
    Lyon, France
    Posts
    18
    Thanks
    1
    Qt products
    Qt5
    Platforms
    Unix/X11

    Default QMenu take Main Window focus

    Hi!

    I have some weird behaviours when I try to open Dialog Windows.
    After some test, I think that the problem come from my menu bar (I can reproduce the same behaviour without opening windows).

    When I click on an empty QMenu (without QAction inside), nothing happen and nothing change (which is normal).
    But when I click on a QMenu with QAction inside (a drop-down menu), that's where things are weird. The QAction don't do anything, they are not link to a slot or anything else. When I click on such a QMenu, without clicking or even hovering the QAction, I "lose" the focus on my Main Window.
    By that I mean that I can't resize my Main Window, nor move it with my mouse.

    Even weirder ? All the buttons inside the Main Window and their associated actions are still working. I use my Central Widget to catch mouse events (to interact with some data), and this still works too (before and after I clicked on the QMenu). The QAction in the Menu Bar are still working.

    Its like the Main Window frame lose the focus....

    Do you know why this happen and/or how to get the focus back to Main Window ?

  2. #2
    Join Date
    Nov 2019
    Location
    Lyon, France
    Posts
    18
    Thanks
    1
    Qt products
    Qt5
    Platforms
    Unix/X11

    Default Re: QMenu take Main Window focus

    I solved the probelm. My centralWidget grabbed to keyboard for some of its functionnalities. I just commented the line "grabKeyboard()" and everything function as intended..

Similar Threads

  1. Replies: 5
    Last Post: 14th December 2011, 02:55
  2. Replies: 7
    Last Post: 23rd April 2011, 03:29
  3. Window focus issues (How to force focus to a window?)
    By montylee in forum Qt Programming
    Replies: 3
    Last Post: 25th April 2009, 02:00
  4. Replies: 11
    Last Post: 11th August 2008, 10:14
  5. Replies: 5
    Last Post: 5th August 2006, 00:44

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.