user826955
user826955

Reputation: 3206

QML Menu remains highlighted/open after clicking and selecting a MenuItem

In my QML application (QT 5.11.3 on Debian) I have the following menu code:

ApplicationWindow {
   id: window
   visible: true

   height: 600
   width: 400

   menuBar: MenuBar {
      id: menuBar
      Menu {
         id: menuFile
         title: "File"

         MenuItem {
            text: "Open"
            onClicked: {
               menuFile.dismiss()               // no effect?
               mainPage.openNew()
            }
         }

      }
   }
}

Now the problem is, that once I click the menu entry File to bring up the menu, and then click anywhere other than File again (e.g. outside of the menu, or a menu entry), the File entry in the menu bar remains highlighted, like this (right-most):

enter image description here

This is especially annoying since in order to open the menu again after this happens, you actually have to click File twice (once to "close" from the previous opening, second time to open it again).

Do I have to add some special code to manually "close" the menu after "usage"? This feels pretty weird. I have also added menuFile.dismiss() hoping it would close the File menu as I would manually do when clicking it again, but it does not change anything.

What am I missing?

Upvotes: 0

Views: 818

Answers (1)

Mackeli
Mackeli

Reputation: 26

I'm running into the same issue on 5.11.3. I believe the issue is fixed in later versions by https://bugreports.qt.io/browse/QTBUG-71583. The issue does not occur on 5.12.3.

Upvotes: 1

Related Questions