koan
koan

Reputation: 3686

Using stylesheets for QToolButton menu

How does one style the drop down menu attached to a QToolButton ?

I have tried QToolButton::menu, QToolButton::drop-down and QMenu#myObject

Upvotes: 1

Views: 3208

Answers (2)

cppguy
cppguy

Reputation: 3723

Posting my comment as the answer:

"try setting the stylesheet on the menu associated with the tool button directly"

Upvotes: 2

Kirell
Kirell

Reputation: 9838

In fact it is a QComboBox, here is a stylesheet I use to customize the comboxbox.

QComboBox {
    border: 1px solid rgb(95, 95, 95);
    border-radius: 3px;
    /*padding: 1px 18px 3px 3px;*/
    /*min-width: 6em*/;
    color: rgb(220, 220, 220);
    margin: 0 0 0 0;
}

QComboBox:editable {
    background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,
                                  stop: 0 rgb(51, 51, 51), stop: 0.4 rgb(39, 39, 39),
                                  stop: 0.5 rgb(32,32,32), stop: 1.0 rgb(38,38,38));
}

QComboBox:!editable {
    background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,
                                  stop: 0 rgb(51, 51, 51), stop: 0.4 rgb(39, 39, 39),
                                  stop: 0.5 rgb(32,32,32), stop: 1.0 rgb(38,38,38));
}

QComboBox::drop-down:editable {
}

QComboBox:!editable:on {
}

QComboBox::drop-down:editable:on {
}

QComboBox:on { /* shift the text when the popup opens */
   /* padding-top: 3px;
    padding-left: 4px;*/
        background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,
                                  stop: 0 rgb(51, 51, 51), stop: 0.4 rgb(39, 39, 39),
                                  stop: 0.5 rgb(32,32,32), stop: 1.0 rgb(38,38,38));
}

QComboBox::drop-down {
    subcontrol-origin: padding;
    subcontrol-position: center right;
    width: 15px; 
      right:3px;
    border-top-right-radius: 3px; /* same radius as the QComboBox */
    border-bottom-right-radius: 3px;
      background:none;
}

QComboBox::down-arrow {
    image: url(:/images/arrow-down-inverted.png);
    height: 10px;
}

QComboBox::down-arrow:on { /* shift the arrow when popup is open */
    top: 1px;
    left: 1px;
}

Upvotes: 0

Related Questions