Stylesheet for ActionsContextMenu - how to?
I have QTreeView with custom background color. When I add ActionsContextMenu via
ui.view->setContextMenuPolicy(Qt::ActionsContextMenu); the background of the pop-up window is the same as in background color of treeview.
Question: how to set up background color of actioncontextmenu?
Re: Stylesheet for ActionsContextMenu - how to?
Quote:
Originally Posted by
QPlace
Question: how to set up background color of actioncontextmenu?
Try this:
Code:
background-color: #ABABAB; /* sets background of the menu */
border: 1px solid black;
}
Re: Stylesheet for ActionsContextMenu - how to?
I don't see ActionsContextMenu being exposed for editing in Qt Designer. My guess is that your advise is applicable only if I can get ContextMenu from QWidget programmatically
Looking through QWidget docs I can't find a way to retrieve this type of menu. :eek:
Or - may be there is a way to get this menu for editing in Qt Designer?
Re: Stylesheet for ActionsContextMenu - how to?
I meant,
Call:
Code:
qApp->setStyleSheet();
And pass the string in this, and check the results.
Like this:
Code:
QString ss
("QMenu{background-color: #ABABAB;border: 1px solid black;}");
qApp->setStyleSheet(ss);
Re: Stylesheet for ActionsContextMenu - how to?
Perfect. The only change I made is that I set setStyleSheet against control where I am setting the actionContextMenu. Setting it against application instance changes the main menu but not actionContextMenu in the control that I am interersted in.
I suspect that it does not change in my case because I am setting custom stylesheet for the control _after_ application receives stylesheet change. I'll check it later.
No. Changing stylesheet on QApp level does not change the stylesheet for the control's menu. Has to be done explicitly for the control.
Thanks again!
Re: Stylesheet for ActionsContextMenu - how to?
Quote:
Originally Posted by
QPlace
No. Changing stylesheet on QApp level does not change the stylesheet for the control's menu. Has to be done explicitly for the control.
Then do it !;)