Trolltech Home | Qt-interest Home | Recent Threads | All Threads | Author | Date
All threads index page 6

Qt-interest Archive, July 2007
QMenu::item and stylesheets


Message 1 in thread

I am trying to set the background of a QMenu with a stylesheet but the items
don't take the background-color selector that I set for the QMenu with the
following stylesheet:

  m_mainMenu->setStyleSheet("QMenu { background-color: #171512;"

                            "color: #B8C1C6;"

                            "font-family: Arial;"

                            "font-size: 11px;"

                            "border: 1px solid black;"

                            "}");


When I set background-color for QMenu::item then the items don't change
color when the mouse hovers over them, like in the following stylesheet:

                            "QMenu::item { "

                            "background-color: #171512"

                            " }"

I've tried the hover and !hover pseudo-states for QMenu::item and it doesn't
seem to make a difference. This seems to be a new problem in qt-4.3.0.

Thanks

-- 
 [ signature omitted ] 

Message 2 in thread

Patrick Stinson wrote:
> I've tried the hover and !hover pseudo-states for QMenu::item and it 
> doesn't seem to make a difference. This seems to be a new problem in 
> qt-4.3.0.
> 

Use the selected pseudo state instead of hover. 'selected' because the 
menu items can be selected using the keyboard too. Try something like,

QMenu {
     background-color: #171512; /* sets background of the menu */
     color: #B8C1C6;
     font-family: Arial;
     font-size: 11px;
     border: 1px solid black;
}

QMenu::item {
     background-color: transparent; /* sets background of menu item. set 
this to something non-transparent if you want menu color and menu item 
color to be different */
}

QMenu::item:selected {
     background-color: red; /* different color when item is selected */
}

Girish

--
 [ signature omitted ] 

Message 3 in thread

That seems to work, thanks.

On 7/29/07, Girish Ramakrishnan <girish@xxxxxxxxxxxxx> wrote:
>
> Patrick Stinson wrote:
> > I've tried the hover and !hover pseudo-states for QMenu::item and it
> > doesn't seem to make a difference. This seems to be a new problem in
> > qt-4.3.0.
> >
>
> Use the selected pseudo state instead of hover. 'selected' because the
> menu items can be selected using the keyboard too. Try something like,
>
> QMenu {
>      background-color: #171512; /* sets background of the menu */
>      color: #B8C1C6;
>      font-family: Arial;
>      font-size: 11px;
>      border: 1px solid black;
> }
>
> QMenu::item {
>      background-color: transparent; /* sets background of menu item. set
> this to something non-transparent if you want menu color and menu item
> color to be different */
> }
>
> QMenu::item:selected {
>      background-color: red; /* different color when item is selected */
> }
>
> Girish
>
> --
> To unsubscribe - send a mail to qt-interest-request@xxxxxxxxxxxxx with
> "unsubscribe" in the subject or the body.
> List archive and information: http://lists.trolltech.com/qt-interest/
>
>


-- 
 [ signature omitted ]