Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

QMenu and QT_SCALE_FACTOR



  • Hi!

    I have a problem with the display of a QMenu and with a parameter QT_SCALE_FACTOR < 1.0

    With a parameter QT_SCALE_FACTOR == 1.0, the display is completely normal.
    1x.png

    With a Parameter QT_SCALE_FACTOR == 1.5, the display is also normal and the size of the menu is multiplied by 1.5.
    15x.png

    On the other hand, when QT_SCALE_FACTOR < 1.0, the display is incorrect, the text is cut off and the highlighting (here in blue) of the menus is incorrect.
    07.png
    (here with QT_SCALE_FACTOR = 0.7)

    How can I correct this?

    Thanx!


  • Lifetime Qt Champion

    What Qt version do you use? Can you add a pixmap - I would guess it's not getting scaled so we can't shrink the menu items.



  • I use qt 5.14

    I get a better result if I change the menu style by reducing, among other things, the font size. But the behavior of items hovered with the mouse is Strange

    myMenu.setStyleSheet("QMenu {background-color: rgb(234,234,234);}"
    			"QMenu::item{ font-family: Arial; font-size: 8pt; color: #111111; padding: 2px 2px 2px 2px; border: 0px solid transparent; background: transparent; }"
    			"QMenu::item:selected {background-color: rgb(0, 255, 255);  border: 0px solid transparent; color: #111111;}"
    			"QMenu::separator { height: 2px; margin: 2px 1px 2px 1px; }"
    			"QMenu::indicator {width: 1px; height: 1px; }");
    

    Untitled-1.png


Log in to reply