Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. [SOLVED] QMenuBar styling - hovering item
Qt 6.11 is out! See what's new in the release blog

[SOLVED] QMenuBar styling - hovering item

Scheduled Pinned Locked Moved General and Desktop
15 Posts 3 Posters 18.1k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    maximus
    wrote on last edited by
    #6

    Anyway this code is for windows only, I gave up on it for now.

    on mac os no styling is applied and it's working fine.
    on windows 8.1, the ::item:hover is not applied but the rest of the stylesheet is working


    Free Indoor Cycling Software - https://maximumtrainer.com

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #7

      I wonder if this is a limitation of the style sheet or a bug on windows...

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • M Offline
        M Offline
        maximus
        wrote on last edited by
        #8

        I think it's a bug on Windows 8.1

        I'm back on windows 7 after uninstalling that **%% and hovering is working fine with this code:

        @/********************************* QMenuBar **********************************/

        QMenuBar {
        background-color: transparent;
        }

        QMenuBar::item {
        color : white;
        margin-top:4px;
        spacing: 3px;
        padding: 1px 10px;
        background: transparent;
        border-radius: 4px;
        }

        QMenuBar::item:selected { /* when selected using mouse or keyboard */
        background: #a8a8a8;
        }

        QMenuBar::item:pressed {
        background: #888888;
        }@

        Solution :
        1-Uninstall Windows 8.1
        2-install a good OS


        Free Indoor Cycling Software - https://maximumtrainer.com

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #9

          You should however consider opening a report about that, at least to let the developers known there's something fishy going on with Windows 8.1

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          0
          • R Offline
            R Offline
            ray4qt
            wrote on last edited by
            #10

            It's not the operating system.

            @QMenuBar::item:hover@

            is incorrect, rather counter-intuitively actually.

            @QMenuBar::item:selected@

            is correct and works as expected on my Windows 8.1 system.

            That change was made in the last code example posted by maximus, presumably after he switched operating systems, so naturally it works.

            1 Reply Last reply
            0
            • M Offline
              M Offline
              maximus
              wrote on last edited by
              #11

              It's true I changed the stylesheet from "item:hover" to "item:selected", I thought it was the OS.
              I'll make sure to use "item:selected" instead of "item:hover" for item stylesheet so it works on all OS

              Thanks


              Free Indoor Cycling Software - https://maximumtrainer.com

              1 Reply Last reply
              0
              • SGaistS Offline
                SGaistS Offline
                SGaist
                Lifetime Qt Champion
                wrote on last edited by
                #12

                hover vs selected is relative. You could very well have your cursor going over the menubar entries without having clicked on them, that would be hovering, wouldn't it ?

                Interested in AI ? www.idiap.ch
                Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                1 Reply Last reply
                0
                • M Offline
                  M Offline
                  maximus
                  wrote on last edited by
                  #13

                  well for now selected act like hovering it seems.
                  I use item::selected and when I hover it, it change according to ::selected stylesheet
                  Don't know why they are two stylesheet name for it, i'm just happy as long at it works :)


                  Free Indoor Cycling Software - https://maximumtrainer.com

                  1 Reply Last reply
                  0
                  • R Offline
                    R Offline
                    ray4qt
                    wrote on last edited by
                    #14

                    When it comes to menu bars we have to use :selected. It does seem strange, but perhaps this is because the standard behavior, at least on Windows, is the color doesn't change between a hover and a click, so a separate setting for a hover is superfluous. Just a guess on my part.

                    This behavior is the same on my Chakra Linux running KDE, but I don't know about the Gnome desktop or indeed the Mac. The fact the Qt developers made this choice makes me think this is common.

                    Just a little "gotcha" along the way.

                    1 Reply Last reply
                    0
                    • SGaistS Offline
                      SGaistS Offline
                      SGaist
                      Lifetime Qt Champion
                      wrote on last edited by
                      #15

                      That might simply be related to QMenu being used elsewhere like in a contextual menu.

                      However, if there's indeed a difference of handling between menubar and contextual QMenu, that should be mentioned in the documentation.

                      Interested in AI ? www.idiap.ch
                      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                      1 Reply Last reply
                      0

                      • Login

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • Users
                      • Groups
                      • Search
                      • Get Qt Extensions
                      • Unsolved