Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-55092

QMenu StyleSheet doesn't work properly.

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Cannot Reproduce
    • Icon: P4: Low P4: Low
    • None
    • 5.6.1
    • Widgets: Style Sheets
    • None

      Applied the following StyleSheet to the QMenu:

      			"QMenu {"
      				"border:0px;"
      				"background-color: transparent;"
      				"icon-size: 36px;"
      			"}"
      			"QMenu::item {"
      			   "border:1px solid #8f8f91;"
      			   "background-color: black;"
      				"color:#FFFFFF;" // text color
      				"padding:10px;"
       				"padding-left:36px;"
      				 "icon-size: 36px;"
      			 "}"
      			"QMenu::item::disabled {"
      				"background-color:#505050;"
      				"color:#C0C0C0;" // text color
      				"icon-size: 36px;"
      			"}"
      			"QMenu::item::selected {"
      				"background-color:rgb(255,152,4);"
      				"color:#FFFFFF;" // text color
      				"icon-size: 36px"
      			"}"
      			"QMenu::item::pressed {"
      				"background-color:rgb(255,152,4);"
      				"color:#FFFFFF;"
      				"icon-size: 36px;"
      			"}"
      			"QMenu::icon {"
      				"icon-size: 36px;"
      			"}"
      			"QMenu::indicator {"
      				"width: 36px;"
      				"height: 36px;"
      				"icon-size: 36px;"
      			"}"
      
      			"QMenu::indicator:non-exclusive:checked {"
      				"image: url(://res/checkbox_checked.png);"
      			"}"
      			"QMenu::indicator:non-exclusive:unchecked {"
      				"image: url(://res/checkbox_unchecked.png);"
      			"}"
      			"QMenu::indicator:exclusive:checked {"
      				"image: url(://res/radio_checked.png);"
      			"}"
      			"QMenu::indicator:exclusive:unchecked {"
      				"image: url(://res/radio_unchecked.png);"
      			"}"
      			"QMenu::separator {"
      				"height:2px;"
      				"background: white;"
      				"margin-left: 0px;"
      				"margin-right: 0px;"
      			"}"
      

      The result is attached.
      Note that icon (2 bottom items) is drawn incorrectly - its size is default - 20px although the space (for icon) is properly reserved
      The reason is that at qstylesheetstyle.cpp line 3589
      pixmap = mi.icon.pixmap(pixelMetric(PM_SmallIconSize), mode, QIcon::On);

      • pixelMetric(PM_SmallIconSize) returns 20
        although call to pixelMetric(PM_SmallIconSize) from qmenu.cpp line 281
        icone = style->pixelMetric(QStyle::PM_SmallIconSize, &opt, q);
      • returns correctly 36 (from the StyleSheet).

        1. qmenu.png
          qmenu.png
          10 kB
        2. QTBUG-55092.png
          QTBUG-55092.png
          7 kB
        3. QTBUG-55092.ZIP
          85 kB
        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

            qt.team.quick.subscriptions Qt Quick and Widgets Team
            vladxky Vlad
            Votes:
            1 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated:
              Resolved:

                There are no open Gerrit changes