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. How to Style Hover on QMenu's Tear-off Area?
Qt 6.11 is out! See what's new in the release blog

How to Style Hover on QMenu's Tear-off Area?

Scheduled Pinned Locked Moved Solved General and Desktop
3 Posts 2 Posters 482 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.
  • O Offline
    O Offline
    Oliver2025
    wrote on last edited by
    #1

    I'm attempting to customize the hover style for the tear-off area of a QMenu using the following CSS, but it seems to have no effect:

    QMenu::tearoff:hover {
        color: red;
    }
    

    Does anyone know why this CSS doesn't work, or how to properly style the hover state for a tear-off area?
    Thanks for any help!

    1 Reply Last reply
    0
    • O Offline
      O Offline
      Oliver2025
      wrote on last edited by Oliver2025
      #3

      Sorry for the late reply—I actually forgot I had posted on the forum! I've now resolved the style sheet issue, and it's working as expected. Here's the snippet I used:

      QMenu::tearoff { background-color: #1A1A1A; height: 12px; border: none; 
                       background-image: url(linkIcons:menuLine2.png);}
      QMenu::tearoff:selected { background-color: #4D4D4D; height: 12px;}
      

      08fd5954be0b64ef04c338de6d36188d.png

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

        Hi and welcome to devnet,

        You should provide a minimal compilable example that shows your issue.
        Note that I am not sure that the tear off supports the hover state.

        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
        2
        • Pl45m4P Pl45m4 referenced this topic on
        • O Offline
          O Offline
          Oliver2025
          wrote on last edited by Oliver2025
          #3

          Sorry for the late reply—I actually forgot I had posted on the forum! I've now resolved the style sheet issue, and it's working as expected. Here's the snippet I used:

          QMenu::tearoff { background-color: #1A1A1A; height: 12px; border: none; 
                           background-image: url(linkIcons:menuLine2.png);}
          QMenu::tearoff:selected { background-color: #4D4D4D; height: 12px;}
          

          08fd5954be0b64ef04c338de6d36188d.png

          1 Reply Last reply
          1
          • SGaistS SGaist has marked this topic as solved on

          • Login

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