Hi!
When I set palette on QMenu it doesn't seem to be working. The following is the code
Selector_Menu
::Selector_Menu(QWidget *parent
) : QMenu(parent
){
setMinimumWidth(52);
setAutoFillBackground(true);
setPalette(p);
}
Selector_Menu::Selector_Menu(QWidget *parent) : QMenu(parent)
{
setMinimumWidth(52);
setAutoFillBackground(true);
QPalette p = palette();
p.setColor(QPalette::Window, QColor(5, 5, 5));
setPalette(p);
}
To copy to clipboard, switch view to plain text mode
I add actions to this menu from the function where I create this object. Something like this
menu = new Selector_Menu(this);
currentAction = menu->addAction("A");
menu->addSeparator();
menu->addAction("B");
menu->addSeparator();
menu->addAction("C");
menu = new Selector_Menu(this);
currentAction = menu->addAction("A");
menu->addSeparator();
menu->addAction("B");
menu->addSeparator();
menu->addAction("C");
To copy to clipboard, switch view to plain text mode
Output looks like the Picture1 attached
When I use stylesheets I get the output which looks like the Picture2 attached
RMS_Output_Assignment_Selector_Menu
::RMS_Output_Assignment_Selector_Menu(QWidget *parent
) : QMenu(parent
){
setMinimumWidth(52);
setAutoFillBackground(true);
QString menu_ss
= "QMenu { color: white; background-color: black; }" + QString("QMenu::item:selected { color: grey; background-color: black; }");
setStyleSheet(menu_ss);
}
RMS_Output_Assignment_Selector_Menu::RMS_Output_Assignment_Selector_Menu(QWidget *parent) : QMenu(parent)
{
setMinimumWidth(52);
setAutoFillBackground(true);
QString menu_ss = "QMenu { color: white; background-color: black; }" +
QString("QMenu::item:selected { color: grey; background-color: black; }");
setStyleSheet(menu_ss);
}
To copy to clipboard, switch view to plain text mode
Any idea on why is the background not being set properly in the menu. I am using Qt 4.3.1
Thanks a lot for the help
Bookmarks