Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

MenuBarItem remains highlighted after mouse over



  • SOLUTION: add hoverEnabled: true to MenuBar.


    When hovering a MenuBarItem the item remains highlighted after I move the mouse away.
    Video https://i.imgur.com/xw53pUD.mp4

    import QtQuick 2.13
    import QtQuick.Controls 2.13
    
    ApplicationWindow {
        id: window
        width: 320
        height: 260
        visible: true
    
        menuBar: MenuBar {
            Menu {
                title: qsTr("&File")
                Action { text: qsTr("&New...") }
                Action { text: qsTr("&Open...") }
                Action { text: qsTr("&Save") }
                Action { text: qsTr("Save &As...") }
                MenuSeparator { }
                Action { text: qsTr("&Quit") }
            }
            Menu {
                title: qsTr("&Edit")
                Action { text: qsTr("Cu&t") }
                Action { text: qsTr("&Copy") }
                Action { text: qsTr("&Paste") }
            }
            Menu {
                title: qsTr("&Help")
                Action { text: qsTr("&About") }
            }
        }
    }
    

    Any way to remove the highlighting when mouse leaves the item?

    Operating System: openSUSE Tumbleweed 20200114
    KDE Plasma Version: 5.17.5
    KDE Frameworks Version: 5.66.0
    Qt Version: 5.13.1



  • Hi,
    For me it looks more like QQC2 style (Plasma/Kirigami) bug than anything other.
    Try i.e.:

    export QT_QUICK_CONTROLS_STYLE=Fusion
    

    before calling Your example.
    There is not highlight at all in Fusion style (in others I tried neither).



  • @SeeLook said in MenuBarItem remains highlighted after mouse over:

    There is not highlight at all in Fusion style (in others I tried neither)

    That's because they don't have hoverEnabled: true, if I add it I get the same behaviour.



  • //...
    menuBar: MenuBar {
        hoverEnabled: true
        Menu {
    //...
    

    Indeed...
    But in that case it behaves much more polite: highlight disappears when mouse goes out of tool bar.
    Isn't it bearable enough for You?



  • @SeeLook said in MenuBarItem remains highlighted after mouse over:

    menuBar: MenuBar {
    hoverEnabled: true
    Menu {

    I meant the MenuBarItem.qml of Fusion was missing hoverEnabled: true and that's were I added it.
    Didn't think of adding it to MenuBar, which does indeed work. Still weird that I have to do that.

    Thanks.



  • OK.
    So, probably the correct way is to call a bug of QQC2 where this hoverEnabled: true statement is missing or so.
    And maybe still, use it as a workaround in custom code.

    And little bit philosophically: I was wondering why it has been unseen so far. Maybe with quite modern QML, a Menu Bar is something rarely in use this days. I can't mention any QML app I know/use with that. Personally I don't use it as well.
    But it is subjective (very), so just ignore me in that matter.



  • @SeeLook said in MenuBarItem remains highlighted after mouse over:

    And little bit philosophically: I was wondering why it has been unseen so far. Maybe with quite modern QML, a Menu Bar is something rarely in use this days. I can't mention any QML app I know/use with that. Personally I don't use it as well.
    But it is subjective (very), so just ignore me in that matter.

    I think people are not using qml much on desktop.
    I know of only one qml application elisa, but it's not using a menu.
    If you know of other open source qml applications please share.



  • If You like, take a look at mine:
    https://nootka.sourceforge.io (beta is on QML) - https://github.com/SeeLook/nootka
    or:
    https://github.com/SeeLook/Metronomek
    But neither of them use Menu Bar.
    Also all KCM modules (Plasma system settings) is on QML and Discover as well but still, no Menu Bar there.
    However do not bother the fashion, just keep using it when You feel it is suitable for Your needs.


Log in to reply