当用户设置焦点时,我想设置菜单项边框的颜色。第一个 - item::selected,这是正确的属性吗?如果是,如何设置?我是使用 Designer 还是在 C++ 代码中手动完成?
Customizing QMenu Individual items of a QMenu are styled using the 'item' subcontrol as follows:
QMenu {
background-color: #ABABAB; /* sets background of the menu */
border: 1px solid black; }
QMenu::item {
/* sets background of menu item. set this to something non-transparent
if you want menu color and menu item color to be different */
background-color: transparent; }
QMenu::item:selected { /* when user selects item using mouse or keyboard */
background-color: #654321; }
好的,但是把它放在 Qt 5.0 的什么地方呢?我是否在样式表属性的Designer中使用它?我觉得不是。在我的 .cpp 文件中?我可以在我的菜单上做,但如何指定 ::item::selected?setStyleSheet
#include "MainWindow.h"
#include <QtWidgets/QWidget>
#include <QtWidgets/QMessageBox>
cf16tradingclient_1::cf16tradingclient_1(){
widget.setupUi(this);
widget.menuMarket->setStyleSheet(?????????) // I want item::selected
}