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 change the position of the menu popped by the qpushbutton?
QtWS25 Last Chance

how to change the position of the menu popped by the qpushbutton?

Scheduled Pinned Locked Moved Unsolved General and Desktop
6 Posts 4 Posters 247 Views
  • 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.
  • nicker playerN Offline
    nicker playerN Offline
    nicker player
    wrote on last edited by
    #1

    I just added the menu and action ,so that if someone clicked the button then the menu would popped on the button.but I found that the menu was very closed to the qpushbutton.so how to change it by using the qss .the way I used was invalid.
    QPushButton QMenu{
    top:-12px;
    border:none;
    border-radius:6px;

    }

    QPushButton QAction{
    font:10px;
    border:none;
    }

    1 Reply Last reply
    0
    • S Offline
      S Offline
      Signal_Slayer
      wrote on last edited by
      #2

      Use menu.popup(button.mapToGlobal(QPoint(x, y))) to set a custom position where x and y adjust the menu's placement relative to the button.

      nicker playerN 1 Reply Last reply
      2
      • S Signal_Slayer

        Use menu.popup(button.mapToGlobal(QPoint(x, y))) to set a custom position where x and y adjust the menu's placement relative to the button.

        nicker playerN Offline
        nicker playerN Offline
        nicker player
        wrote on last edited by
        #3

        @Signal_Slayer
        I knew that.but i just wondered if there's a method that could change the position by using the qss style.

        1 Reply Last reply
        0
        • Christian EhrlicherC Online
          Christian EhrlicherC Online
          Christian Ehrlicher
          Lifetime Qt Champion
          wrote on last edited by
          #4

          qss is for styling. Positioning a widget has nothing to do with styling.

          Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
          Visit the Qt Academy at https://academy.qt.io/catalog

          1 Reply Last reply
          2
          • nicker playerN Offline
            nicker playerN Offline
            nicker player
            wrote on last edited by
            #5

            image.png
            by the way.how to change the outlook of the qcombobox by using the qss.the arrow and the right part is so ugly.it is not the operating system default style.

            jsulmJ 1 Reply Last reply
            0
            • nicker playerN nicker player

              image.png
              by the way.how to change the outlook of the qcombobox by using the qss.the arrow and the right part is so ugly.it is not the operating system default style.

              jsulmJ Offline
              jsulmJ Offline
              jsulm
              Lifetime Qt Champion
              wrote on last edited by
              #6

              @nicker-player said in how to change the position of the menu popped by the qpushbutton?:

              it is not the operating system default style

              What is your OS?
              Did you do any styling already in your app?
              There is documentation which should answer your question: https://doc.qt.io/qt-6/stylesheet-examples.html#customizing-qcombobox

              https://forum.qt.io/topic/113070/qt-code-of-conduct

              1 Reply Last reply
              1

              • Login

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