The easiest way I am trying to create a simple QComboBox
with some color options So far, to make a QPixmap
for each item, fill it with color and use it as an item icon:
this-> ColorComboBox = New QComboBox; This- & gt; Coloring box- & gt; Set icons (QSize (100, 15)); QPixmap color mark (100, 15); This- & gt; Colorful list Push_back (QColor (255, 255, 255, 255)); This- & gt; Color Design Push_back (QColor (194, 169, 160, 255)); This- & gt; Color Design Push_back (QColor (235, 206, 157, 255)); This- & gt; Colorful list Push_back (QColor (254, 121, 5, 255)); This- & gt; Colorful list Push_back (QColor (255, 195, 78, 255)); This- & gt; Color list Push_back (QColor (111, 203, 172, 255)); For (unsigned int i = 0; i & lt; this-> colorList.size (); ++ i) {colorIcon.fill (this-> colorList.at (i)); This- & gt; Coloring box- & gt; AdiTom (color icon, Qestring ("")); }
The problem is, even if the color rectangle for the currently selected item is displayed well on the button:
This popup appears small for items in the list:
< Img src = "https: //i.stack.imgur.com/0Q66h.png" alt = "Enter image details here">
It looks like Pixmap is always smaller than 15px wide No matter what size I choose for setIconSize
I think it should be really simple to solve, but I have tried many things and nothing is working ... thanks in advance QSS QComboBox
. Edit The person grew up, the icon is still small.
QComboBox {border: 1px solid # 101010; Background color: # 808080; Color: # d0d0d0; Boundary-radius: 4px; Selection Color: # f58113; Selection of background color: # 808080; Show-Decoration-Selected: 0; } QComboBox: On {padding-top: -10px; Padding-left: 4px; } QComboBox :: drop-down {subcontrol-origin: padding; Subcontrol-position: top right; Width: 15px; Border-left-width: 0 pixels; Border-left-color: # 000000; Border-left-style: solid; Border-top right-radius: 3px; Border-bottom right-radius: 3px; }
Comments
Post a Comment