Represent drop down menu of QPushButton with Qt Style Sheet?
I'm wondering which is a proper way for representing the menu dropped down from a QPushButton ?
QPushB开发者_如何学Cutton::drop-down { blabla }
doesn't work
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;
}
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.
精彩评论