nwtriada.blogg.se

Qt set icon
Qt set icon







The next screenshot shows the application with an additional file loaded, providing QIcon with two available pixmaps. But in disabled and selected mode, Qt will generate a slightly different pixmap. In this case the pixmap's icon mode is set to normal, and the generated pixmaps for the normal and active modes will look the same. When QIcon is provided with only one available pixmap, that pixmap is used for all the states and modes.

qt set icon

The Guess Image Mode/State is enabled and the style is Plastique. The screenshot above shows the application with one image file loaded. In addition, the File menu provide an Exit option, and the Help menu provide information about the example and about Qt. These last options are also available through a context menu that appears if you press the right mouse button within the table of image files. The File menu provide the options of adding an image and removing all images. The View menu also provide the option to make the application guess the icon state and mode from an image's file name. You can navigate between the available styles using the View menu. The predefined sizes are style dependent, but most of the styles have the same values: Only the Macintosh style differ by using 32 pixels, instead of 16 pixels, for toolbar buttons. The application allows you to manipulate the icon size with some predefined sizes and a spin box. The application provides a sub directory containing sets of images explicitly designed to illustrate how Qt renders an icon in different modes and states. An image can be excluded from this set by checking off the related checkbox. When an image is loaded into the application, it is converted into a pixmap and becomes a part of the set of pixmaps available to the icon. With the Icons application you get a preview of an icon's generated pixmaps reflecting its different states, modes and size. Such pixmaps are used by Qt widgets to show an icon representing a particular action. You can, for example, use the QIcon's states to display differing pixmaps depending on whether the tool button or menu entry is checked or not.Ī QIcon can generate smaller, larger, active, disabled, and selected pixmaps from the set of pixmaps it is given. When a tool button or menu entry is checked, the QIcon's state is On, otherwise it's Off. The most common usage of QIcon's states are when displaying checkable tool buttons or menu entries (see QAbstractButton::setCheckable() and QAction::setCheckable()). QIcon's states are QIcon::On and QIcon::Off, which will display the pixmap when the widget is in the respective state. Qt currently defines four modes: Modeĭisplay the pixmap when the user is not interacting with the icon, but the functionality represented by the icon is available.ĭisplay 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.ĭisplay the pixmap when the functionality represented by the icon is not available.ĭisplay the pixmap when the icon is selected. An icon's state and mode are depending on the intended use of the icon. The QIcon class provides scalable icons in different modes and states. These pixmaps are generated from the set of pixmaps made available to the icon, and are used by Qt widgets to show an icon representing a particular action. The Icons example shows how QIcon can generate pixmaps reflecting an icon's state, mode and size.

  • widgets/icons/images/qt_extended_48x48.png.
  • widgets/icons/images/qt_extended_32x32.png.
  • widgets/icons/images/qt_extended_16x16.png.
  • widgets/icons/images/monkey_on_64圆4.png.
  • widgets/icons/images/monkey_on_32x32.png.
  • widgets/icons/images/monkey_on_16x16.png.
  • widgets/icons/images/monkey_on_128x128.png.
  • widgets/icons/images/monkey_off_64圆4.png.
  • widgets/icons/images/monkey_off_32x32.png.
  • widgets/icons/images/monkey_off_16x16.png.
  • widgets/icons/images/monkey_off_128x128.png.
  • #QT SET ICON CODE#

    Here is the source code if you want to run the program on your PC.ītn.setIcon(self.style().standardIcon(getattr(QStyle, i))) The button names are the QStyle macro names to create QIcon objects. So I wrote a little program to list all the available Qt icons.

    qt set icon qt set icon

    However, I can’t find any page online showing what these icons look like. I know that Qt includes it’s own set of icons. One of the tasks is to put up some icons in the user interface. I was given a job to smarten up a GUI program which is implemented in PyQt.







    Qt set icon