Question

I'm wondering which is a proper way for representing the menu dropped down from a QPushButton ?

QPushButton::drop-down { blabla }

doesn't work

Was it helpful?

Solution

When you set the menu for a QPushButton using setMenu(), the menu continues to exist as its own entity so you would target the QMenu object itself with an appropriate selector. A QMenu supports the box model. Some example styling can be found here.

OTHER TIPS

In QT Style Sheets, you can style widgets that are members of other widgets like so:

QPushButton QMenu
{
    /* blahblah */
}

Where QPushButton is the parent widget, and QMenu is the child. It also works for other stylable items and pseudo-states, for example

QPushButton QMenu::separator
{
    height: 1px;
    border-bottom: 1px solid lightGray;
    background: #5A5A5A;
    margin-left: 2px;
    margin-right: 0px;
    margin-top: 2px;
    margin-bottom: 2px;
 }
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top