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. QToolButton Menu Arrow Position Issue (Windows 7)
Forum Updated to NodeBB v4.3 + New Features

QToolButton Menu Arrow Position Issue (Windows 7)

Scheduled Pinned Locked Moved General and Desktop
5 Posts 3 Posters 4.9k 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.
  • jazzycamelJ Offline
    jazzycamelJ Offline
    jazzycamel
    wrote on last edited by
    #1

    Hi folks,

    I have some QToolButton's in tool bars, both in the main tool bar and window tool bars, that use either the QToolButton::DelayedPopup or QToolButton::InstantPopup flags. In these modes, the menu indicator (a downward pointing arrow) is integrated into the button rather than providing an explicit menu button as in the QToolButton::MenuButtonPopup mode. Functionally this works fine but on Windows 7 (and other versions?) the style fails to add extra room to the button for this indicator and ends up drawing over the buttons icon. This is not the case on either Mac OSX (10.8) or Linux (Mint 13 Maya). The images below illustrate the issue:

    !http://s10.postimage.org/dmdmoxcn9/tb_mac.png(QToolButton on Mac OSX)!
    Mac OSX: Gives just enough room

    !http://s10.postimage.org/79yhf39l1/tb_nix.png(QToolButton on Linux Mint)!
    Linux: Gives ample room

    !http://s10.postimage.org/x6s5rpd8l/tb_win7.png(QToolButton on Windows 7)!
    Windows 7: Note the encroachment of the arrow on the icon. With a square icon, the arrow obscures the bottom corner and gets lost.

    Has anyone got any ideas how to fix this or style around the problem? All help gratefully received.

    For the avoidance of doubt:

    1. All my code samples (C++ or Python) are tested before posting
    2. As of 23/03/20, my Python code is formatted to PEP-8 standards using black from the PSF (https://github.com/psf/black)
    RokeJulianLockhartR 1 Reply Last reply
    0
    • G Offline
      G Offline
      goblincoding
      wrote on last edited by
      #2

      Have you had a look at "style sheets":http://qt-project.org/doc/qt-4.8/stylesheet-examples.html#customizing-qtoolbutton ?

      http://www.goblincoding.com

      1 Reply Last reply
      1
      • jazzycamelJ jazzycamel

        Hi folks,

        I have some QToolButton's in tool bars, both in the main tool bar and window tool bars, that use either the QToolButton::DelayedPopup or QToolButton::InstantPopup flags. In these modes, the menu indicator (a downward pointing arrow) is integrated into the button rather than providing an explicit menu button as in the QToolButton::MenuButtonPopup mode. Functionally this works fine but on Windows 7 (and other versions?) the style fails to add extra room to the button for this indicator and ends up drawing over the buttons icon. This is not the case on either Mac OSX (10.8) or Linux (Mint 13 Maya). The images below illustrate the issue:

        !http://s10.postimage.org/dmdmoxcn9/tb_mac.png(QToolButton on Mac OSX)!
        Mac OSX: Gives just enough room

        !http://s10.postimage.org/79yhf39l1/tb_nix.png(QToolButton on Linux Mint)!
        Linux: Gives ample room

        !http://s10.postimage.org/x6s5rpd8l/tb_win7.png(QToolButton on Windows 7)!
        Windows 7: Note the encroachment of the arrow on the icon. With a square icon, the arrow obscures the bottom corner and gets lost.

        Has anyone got any ideas how to fix this or style around the problem? All help gratefully received.

        RokeJulianLockhartR Offline
        RokeJulianLockhartR Offline
        RokeJulianLockhart
        wrote on last edited by RokeJulianLockhart
        #3

        I have some QToolButton's in tool bars, both in the main tool bar and window tool bars, that use either the QToolButton::DelayedPopup or QToolButton::InstantPopup flags. In these modes, the menu indicator (a downward pointing arrow) is integrated into the button rather than providing an explicit menu button as in the QToolButton::MenuButtonPopup mode.

        @jazzycamel, I've the same. An example is undermentioned.

        On Windows 7 (and other versions?) the style fails to add extra room to the button for this indicator and ends up drawing over the buttons icon.

        Interestingly, I've the opposite in this regard – too much padding in the QToolButton's minimum size's width, in comparison to its QPushButton counterparts:

        2c6156c9-805e-461d-9edd-185cca105f32-Screenshot_20250208_235121.png

        Did you ever ascertain how to remediate this?

        qt-project.org/doc/qt-4.8/stylesheet-examples.html#customizing-qtoolbutton

        @goblincoding, I too believe it might be a deficiency in whatever application style we're using. If either of you can confirm, that'll be helpful.

        Source
        button = PyQt6.QtWidgets.QToolButton()
        button.setPopupMode(PyQt6.QtWidgets.QToolButton.ToolButtonPopupMode.MenuButtonPopup)
        button.setArrowType(PyQt6.QtCore.Qt.ArrowType.NoArrow)
        button.setToolButtonStyle(PyQt6.QtCore.Qt.ToolButtonStyle.ToolButtonFollowStyle)
        button.setText("Overflow")
        

        When using a forum, remember to tag the person you are responding to, in case they are not subscribed to the thread.

        RokeJulianLockhartR 1 Reply Last reply
        0
        • RokeJulianLockhartR RokeJulianLockhart

          I have some QToolButton's in tool bars, both in the main tool bar and window tool bars, that use either the QToolButton::DelayedPopup or QToolButton::InstantPopup flags. In these modes, the menu indicator (a downward pointing arrow) is integrated into the button rather than providing an explicit menu button as in the QToolButton::MenuButtonPopup mode.

          @jazzycamel, I've the same. An example is undermentioned.

          On Windows 7 (and other versions?) the style fails to add extra room to the button for this indicator and ends up drawing over the buttons icon.

          Interestingly, I've the opposite in this regard – too much padding in the QToolButton's minimum size's width, in comparison to its QPushButton counterparts:

          2c6156c9-805e-461d-9edd-185cca105f32-Screenshot_20250208_235121.png

          Did you ever ascertain how to remediate this?

          qt-project.org/doc/qt-4.8/stylesheet-examples.html#customizing-qtoolbutton

          @goblincoding, I too believe it might be a deficiency in whatever application style we're using. If either of you can confirm, that'll be helpful.

          Source
          button = PyQt6.QtWidgets.QToolButton()
          button.setPopupMode(PyQt6.QtWidgets.QToolButton.ToolButtonPopupMode.MenuButtonPopup)
          button.setArrowType(PyQt6.QtCore.Qt.ArrowType.NoArrow)
          button.setToolButtonStyle(PyQt6.QtCore.Qt.ToolButtonStyle.ToolButtonFollowStyle)
          button.setText("Overflow")
          
          RokeJulianLockhartR Offline
          RokeJulianLockhartR Offline
          RokeJulianLockhart
          wrote on last edited by RokeJulianLockhart
          #4

          I've the opposite in this regard – too much padding in the QToolButton's minimum size's width, in comparison to its QPushButton counterparts.

          @RokeJulianLockhart, I wasn't aware that the drop-down indicator is dynamically applied based upon how many QAction entries that the QMenu connected to the QToolButton has applied:

          button = PyQt6.QtWidgets.QToolButton()
          button.setPopupMode(PyQt6.QtWidgets.QToolButton.ToolButtonPopupMode.MenuButtonPopup)
          button.setArrowType(PyQt6.QtCore.Qt.ArrowType.NoArrow)
          button.setToolButtonStyle(PyQt6.QtCore.Qt.ToolButtonStyle.ToolButtonFollowStyle)
          button.setText("Overflow")
          
          button_menu = PyQt6.QtWidgets.QMenu()
          button_action = PyQt6.QtGui.QAction().setText("Test")
          button_menu.addAction(button_action)
          button.setMenu(button_menu)
          

          ...produces:

          8b777019-cf80-41a8-bd15-8a00819bce73-Screenshot_20250209_010631.png

          That's better, although I'd still prefer it were more like the undermentioned:

          9422465f-2578-430f-b5ad-f22c493b29a9-Screenshot_20250209_010627.png

          It appears as if the padding width being too small on the drop-down indicators when a QMenu with QActions is attached (and their absence when no QMenu is attached isn't taken into account) cause this.

          When using a forum, remember to tag the person you are responding to, in case they are not subscribed to the thread.

          1 Reply Last reply
          0
          • jazzycamelJ Offline
            jazzycamelJ Offline
            jazzycamel
            wrote on last edited by
            #5

            @RokeJulianLockhart not gonna lie, this was over 12 years ago and I can’t even remember which project this question related to, sorry πŸ˜”

            For the avoidance of doubt:

            1. All my code samples (C++ or Python) are tested before posting
            2. As of 23/03/20, my Python code is formatted to PEP-8 standards using black from the PSF (https://github.com/psf/black)
            1 Reply Last reply
            2

            • Login

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