在qt designer中我们可以看到,一些控件允许设置图标,然后在它下面会出现很多项目
对这些不同项目的解释见 enum QIcon::Mode
Constant | Value | Description |
---|---|---|
QIcon::Normal | 0 | Display the pixmap when the user is not interacting with the icon, but the functionality represented by the icon is available. 控件可用时,如果没有检测到交互事件(如鼠标事件),显示该图标 |
QIcon::Disabled | 1 | Display the pixmap when the functionality represented by the icon is not available.控件禁用时,显示该图标 |
QIcon::Active | 2 | Display the pixmap when the functionality represented by the icon is available and the user is interacting with the icon, for example, moving the mouse over it or clicking it. 控件可用时,并且检测到交互事件(如鼠标事件),显示该图标 |
QIcon::Selected | 3 | Display the pixmap when the item represented by the icon is selected. 控件被选中时,显示该图标 |
Constant | Value | Description |
---|---|---|
QIcon::Off | 1 | Display the pixmap when the widget is in an “off” state. 开关控件处于off状态(check)时显示该图标 |
QIcon::On | 0 | Display the pixmap when the widget is in an “on” state. 开关控件处于on状态(uncheck)时显示该图标 |
通过QIcon::addPixmap
和QIcon::addFile
设置不同情况下的图标