May 2019
Intermediate to advanced
542 pages
13h 37m
English
Now consider an icon on a toolbar or in a program menu. When the menu item is disabled, you expect the icon to be grayed out in some way. Likewise, if a user hovers over the button or item using a mouse cursor, you might expect it to be highlighted. To encapsulate this type of state-dependent image display, Qt provides the QIcon class. A QIcon object contains a collection of pixmaps that are each mapped to a widget state.
Here is how you can create a QIcon object:
connect_icon = qtg.QIcon() connect_icon.addPixmap(go_pixmap, qtg.QIcon.Active) connect_icon.addPixmap(stop_pixmap, qtg.QIcon.Disabled)
After creating the icon object, we use its addPixmap() method to assign a QPixmap object to a widget state. These states include
Read now
Unlock full access