Questions tagged [qicon]

A QIcon is a class from the Qt toolkit which provides scalable icons in different modes and states.

A QIcon can generate "small", "large", "active", and "disabled" pixmaps from the set of pixmaps it is given. Such pixmaps are used by Qt widgets to show an icon representing a particular action.

The simplest use of QIcon is to create one from a QPixmap file or resource, and allow Qt to work out all the required icon styles and sizes.

If a pixmap is requested, and no pixmap for that given size, mode and state is available, QIcon will generate one on the fly. This pixmap generation happens in a QIconEngineV2. The default engine scales pixmaps down if required, but never up, and it uses the current style to calculate a disabled appearance.

By using custom icon engines, you can customize every aspect of generated icons. With QIconEnginePluginV2 it is possible to register different icon engines for different file suffixes, making it possible for third parties to provide additional icon engines to those included with Qt.

Since Qt 4.2, an icon engine that supports SVG is also included.

Simple example which describes how QIcon can be used:

QToolButton *button = new QToolButton;
button->setIcon(QIcon("open.xpm"));

The official Qt documentation can be found here.

91 questions
0
votes
0 answers

How to add icon into toolbar QAction

There are problems in loading the icon into the toolbar. Here is the code: ... button_action = QAction('Your button', self) button_action.setStatusTip('This is your…
FlickDUB
  • 9
  • 2
0
votes
1 answer

QListView highlight color not applied to item icon

I'm trying to get the hover highlight color I set on a QListView applied to the items' icons. Right now it only applies to the surroundings (the image has an alpha channel which is 0 where there is white background): You can see clearly that the 3D…
Florian Blume
  • 3,237
  • 17
  • 37
0
votes
1 answer

Add QIcon to QTableView cell

I have already coded this for QTableWidget: void ReadOnlyWindow::addReportIconToRow(const int rowIndex){ QIcon icon; QSize sz(16, 16); icon.addPixmap(style()->standardIcon(QStyle::SP_FileDialogEnd).pixmap(sz), QIcon::Normal); …
Matej Peluha
  • 163
  • 9
0
votes
2 answers

QPushButton not respecting QIcon mode changes

When applying a QIcon with QPushButton::setIcon(), it appears that mode changes don't respect the mode changes set for the QIcon QIcon helpIcon; helpIcon.addPixmap(QPixmap(":/icons/style/help.png"),…
mrg95
  • 2,371
  • 11
  • 46
  • 89
0
votes
0 answers

QIcon in QMenu does not change image with mouse hover or click

I am trying to setup a QIcon for a QMenu that reflects normal, pressed, and disabled states but the image doesn't seem to change when I mouse hover/click over the icon. I have added 3 icons to my resources.qrc file reflecting normal, active, and…
Ankur Shah
  • 125
  • 12
0
votes
1 answer

The icon does not load when you start the application from the outside Qt Creator

I have a *.ico file. The icon is loaded by the setWindowIcon() function. I added a *.ico file to the resource file. When I launch the application from Qt Creator, the icon is displayed correctly. But when I launch the application from outside Qt…
Konstantin
  • 35
  • 1
  • 5
0
votes
0 answers

How to add multiple Icons into QTreeWidgetItem?

I am setting up an user manager and i need to implement User statue policy. I have a list of users in QTreeWidget and each user has its own QTreeWidgetItem. User has some atributes (ban, hasPassword...) and I want to show it instantly in list. bool…
0
votes
1 answer

Are there default icons for use in a QTreeWidget?

I have a QTreeWidget and I want to add icons, are there a default set to pick from such as the file folder in explorer and a blank piece of paper icon?
0
votes
1 answer

Qtreewidget item change color to Icon in Qtreewidgetitem

how change background icon inside a qtreewidgetitem dinamically: Some code example.. if item.text(0)=="INL" item.icon(0).setBackground(Qt.green) else: item.icon(0).setBackground(Qt.yellow) I want only icon background not all item…
user3589887
  • 139
  • 2
  • 13
0
votes
0 answers

"Cannot read file" error when loading an .svg file with PyQt4

I'm having troubles using a .svg icon for my windows icon. From what I have read this is due to a bad installation of the PyQt4 plugins, but I am confused on how to fix it. When I try to load the…
Pinosky
  • 1
  • 1
0
votes
1 answer

Qt 5.7 -> 5.8 add QIcon to QListwidget

I want to upgrade my project from Qt 5.7 to Qt5.8. I have a function which shows an image on a QListWidget. My project, a viewer makes a thumbnail from image and convert it to a QIcon. After creating the QIcon it is added to the QListWidget by…
0
votes
2 answers

QT setColumnWidth does not work in qtablewidget

This is my following code I added an icon to filetable (column 0) but I can't change the width of column 0 void Window::showFiles(const QStringList &files) { int row=0 ; filesTable->clearContents(); for (int i = 0; i < files.size();…
Ss.unix
  • 43
  • 8
0
votes
1 answer

Convert QImage(icon) to grayScale format while keeping background

I want to convert an icon to grayscale format (to give the disable action feedback to user) like this: inline QPixmap grayScaleImage(const QIcon &icon) { int w = icon.availableSizes().at(0).width(); int h =…
IMAN4K
  • 1,265
  • 3
  • 24
  • 42
0
votes
1 answer

Icon in Qt::DecorationRole - causes a crash

I'm writing an application with TableView, custom model (QAbstractTableModel descendant) and icons in cells. Firstly i've tried to make an icons cache, but fall into Access Violation (at address 0x0) while expanding main window with table to…
Elmy
  • 9
  • 3
0
votes
1 answer

Changing fluently brightness of QPushButton icon

I found a function to make QImage brighter and used in my Qt application. I want to show simple "animation" of making button step by step brighter and than again step by step back to initial state after user click it. Here my code: void…
WJuz
  • 37
  • 1
  • 6