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?
Forum Updated to NodeBB v4.3 + New Features

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

Scheduled Pinned Locked Moved Unsolved General and Desktop
6 Posts 4 Posters 272 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.
  • N Offline
    N Offline
    nicker player
    wrote on 20 Feb 2025, 03:42 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 20 Feb 2025, 05:46 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.

      N 1 Reply Last reply 20 Feb 2025, 06:32
      2
      • S Signal_Slayer
        20 Feb 2025, 05:46

        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.

        N Offline
        N Offline
        nicker player
        wrote on 20 Feb 2025, 06:32 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
        • C Offline
          C Offline
          Christian Ehrlicher
          Lifetime Qt Champion
          wrote on 20 Feb 2025, 06:34 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
          • N Offline
            N Offline
            nicker player
            wrote on 20 Feb 2025, 07:14 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.

            J 1 Reply Last reply 20 Feb 2025, 07:18
            0
            • N nicker player
              20 Feb 2025, 07:14

              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.

              J Offline
              J Offline
              jsulm
              Lifetime Qt Champion
              wrote on 20 Feb 2025, 07:18 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

              5/6

              20 Feb 2025, 07:14

              • Login

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