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

QPushButton::drop-down { blabla }

doesn't work

有帮助吗?

解决方案

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.

其他提示

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;
 }
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top