Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt
  • Unsolved
Collapse
qtws26_logo

The Qt Event of the Year: Qt World Summit 2026

Save Your Spot >
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Stylesheet for QMenu leaves a white spot at the end
Qt 6.12 LTS is out! See what's new in the release blog

Stylesheet for QMenu leaves a white spot at the end

Scheduled Pinned Locked Moved Solved General and Desktop
6 Posts 2 Posters 1.1k Views 2 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.
  • S Offline
    S Offline
    Sucharek
    wrote on last edited by
    #1

    Hi, so I don't know why, but when I try to set a stysheet for qmenu items, it leaves a white spot at the end. Here's what it looks like:
    805480de-8f7b-4f58-840d-4f88116e6753-image.png
    Code:

    "QMenu {background-color: white; border: 0.5px solid black;}"
    "QMenu::item {color: black; background-color: transparent;}"
    "QMenu::item:selected {color: white; background-color: rgb(0, 120, 215);}
    

    I tried round corners too, but that makes even more white spots:
    eb67105e-86cb-43e1-8139-5f1f95c459af-image.png
    Code:

    "QMenu {background-color: white; border: 0.5px solid black; border-radius: 10px; padding: 5px;}"
    "QMenu::item {color: black; background-color: transparent;}"
    "QMenu::item:selected {color: white; background-color: rgb(0, 120, 215);}"
    
    Pl45m4P 1 Reply Last reply
    0
    • S Sucharek

      Hi, so I don't know why, but when I try to set a stysheet for qmenu items, it leaves a white spot at the end. Here's what it looks like:
      805480de-8f7b-4f58-840d-4f88116e6753-image.png
      Code:

      "QMenu {background-color: white; border: 0.5px solid black;}"
      "QMenu::item {color: black; background-color: transparent;}"
      "QMenu::item:selected {color: white; background-color: rgb(0, 120, 215);}
      

      I tried round corners too, but that makes even more white spots:
      eb67105e-86cb-43e1-8139-5f1f95c459af-image.png
      Code:

      "QMenu {background-color: white; border: 0.5px solid black; border-radius: 10px; padding: 5px;}"
      "QMenu::item {color: black; background-color: transparent;}"
      "QMenu::item:selected {color: white; background-color: rgb(0, 120, 215);}"
      
      Pl45m4P Offline
      Pl45m4P Offline
      Pl45m4
      wrote on last edited by
      #2

      @Sucharek

      Must be the border or some kind of margin.
      Try to set the margin to 0.

      https://doc.qt.io/qt-5/stylesheet-examples.html#customizing-qmenu


      If debugging is the process of removing software bugs, then programming must be the process of putting them in.

      ~E. W. Dijkstra

      S 1 Reply Last reply
      1
      • Pl45m4P Pl45m4

        @Sucharek

        Must be the border or some kind of margin.
        Try to set the margin to 0.

        https://doc.qt.io/qt-5/stylesheet-examples.html#customizing-qmenu

        S Offline
        S Offline
        Sucharek
        wrote on last edited by
        #3

        Hi @Pl45m4, so I tried your method, which kinda works, but now it looks like this:
        d72a957f-10db-4ea1-8de6-a3627a8b5556-image.png

        Pl45m4P 1 Reply Last reply
        0
        • S Offline
          S Offline
          Sucharek
          wrote on last edited by
          #4

          Hi, so I solved it by adding some padding. (padding: 2px 10px 2px 10px;)
          Thanks for your help.

          1 Reply Last reply
          0
          • S Sucharek

            Hi @Pl45m4, so I tried your method, which kinda works, but now it looks like this:
            d72a957f-10db-4ea1-8de6-a3627a8b5556-image.png

            Pl45m4P Offline
            Pl45m4P Offline
            Pl45m4
            wrote on last edited by Pl45m4
            #5

            @Sucharek

            When I modify the padding of the item + selected item the small white area is gone. But then you probably need to define more setting since it overwrites the default config:

            "QMenu { background-color: white; border: 0.5px solid black;}"
            "QMenu::item { padding: auto; color: black; background-color: transparent;}"
            "QMenu::item:selected { padding: auto; border: 0.5px; color: white; background-color: rgb(0, 120, 215);}"
            

            Play around with padding, margin and border values until it looks like expected :)

            Edit:

            Nice, didn't read your comment. Spent the time trying it myself :)


            If debugging is the process of removing software bugs, then programming must be the process of putting them in.

            ~E. W. Dijkstra

            S 1 Reply Last reply
            2
            • Pl45m4P Pl45m4

              @Sucharek

              When I modify the padding of the item + selected item the small white area is gone. But then you probably need to define more setting since it overwrites the default config:

              "QMenu { background-color: white; border: 0.5px solid black;}"
              "QMenu::item { padding: auto; color: black; background-color: transparent;}"
              "QMenu::item:selected { padding: auto; border: 0.5px; color: white; background-color: rgb(0, 120, 215);}"
              

              Play around with padding, margin and border values until it looks like expected :)

              Edit:

              Nice, didn't read your comment. Spent the time trying it myself :)

              S Offline
              S Offline
              Sucharek
              wrote on last edited by
              #6

              Hi @Pl45m4, thanks for your response.
              I will play around with it, untill I find how I want it to be.
              Thanks for your answer.

              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
              • Unsolved