QToolButton Menu Arrow Position Issue (Windows 7)
-
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.
-
Have you had a look at "style sheets":http://qt-project.org/doc/qt-4.8/stylesheet-examples.html#customizing-qtoolbutton ?
-
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.
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 itsQPushButton
counterparts: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")
-
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 itsQPushButton
counterparts: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")
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 theQMenu
connected to theQToolButton
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:
That's better, although I'd still prefer it were more like the undermentioned:
It appears as if the padding width being too small on the drop-down indicators when a
QMenu
withQActions
is attached (and their absence when noQMenu
is attached isn't taken into account) cause this. -
@RokeJulianLockhart not gonna lie, this was over 12 years ago and I canβt even remember which project this question related to, sorry π