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
19
votes
2 answers

How to change IconSize of QToolButton

How to change the IconSize of QToolButton. button1->setIcon(QIcon("download.jpg")); button1->setFixedSize(100,100); By using above code button size is getting change but icon inside the button is not changing.
Suresh
  • 745
  • 4
  • 11
  • 25
15
votes
3 answers

Qt qrc resource file - can't load icon

I have a Qt5 desktop project and I added a "resource.qrc" file with the Qt Creator editor which created the following line into the project's .pro file: RESOURCES = resource.qrc I put a blank prefix and a png file (14x14) and I tried to use it like…
Johnny Pauling
  • 12,701
  • 18
  • 65
  • 108
15
votes
2 answers

Simple color fill QIcons in Qt

I need to create a menu that changes the background of a QWidget. I'd like to place a QIcon that represents the selected color into the QActions which populates the QMenu. I'd like to not have to pop out Photoshop and paint the icons manually. Is…
jliu83
  • 1,553
  • 5
  • 18
  • 23
9
votes
1 answer

Custom QIcon using QIconEngine and transparency

I'm trying to implement something like "composed icon" in Qt. Target: I need to dynamicaly set color just for the portion of icon. My idea: Compose this icon by two other. One icon that will be coloured as desired (perhaps by ColorizeEffect) and…
GPUquant
  • 245
  • 2
  • 7
8
votes
1 answer

Change disabled QIcon tint color

I have an application with a custom theme and the disabled icons are to brightly grayed. I would like to change the disabled icon tint color. Now I know there is a possibility like this: QTableWidgetItem *name = new QTableWidgetItem("test"); QIcon…
Jacob Krieg
  • 2,834
  • 15
  • 68
  • 140
7
votes
2 answers

How to create custom icons for QFileSystemModel in a background thread

I am making a file browser in qt for some custom design-files. I want to load their preview as their thumbnail and for that reason I am using QIconProvider to return the Icon to my QFileSystemModel. The problem is that the algorithm that creates the…
willy
  • 487
  • 5
  • 21
6
votes
2 answers

How to put system icons in menus?

I have run the menu example from Qt and there are no icons on menus, only text. Most apps (like pcmanfm and caja from Ubuntu) have similar icons, so I suppose they are system-wide and not application specific. How could I put icons in menu items? A…
ProgAndPlay
  • 277
  • 1
  • 12
6
votes
1 answer

How to get the file/resource path for a QIcon

So let's say I do something like this: QIcon myIcon(":/resources/icon.ico"); How can I later determine the path for that icon, e.g. QString path = myIcon.getPath(); The problem is, there is no getPath() member, and I can't find anything similar,…
y2k
  • 65,388
  • 27
  • 61
  • 86
5
votes
6 answers

does not show icons

I just installed Python3 (3.5.2) and Pyqt5 (5.8.2) and I am following this tutorial to learn and make a GUI: http://zetcode.com/gui/pyqt5/firstprograms/ I'm trying to run the 2nd example but program is returning an error (which also happened on the…
Diogo Guerra
  • 128
  • 2
  • 3
  • 12
4
votes
1 answer

Add Icon to Tab (QTabWidget)?

I'm working with a QTabWidget with three Tabs. One of the tab is about Information/Help. So I want to use a picture of a Question Mark (.png) instead of the Text "help". Is this Possible? I'm working with Python/PyQt and I can only find solutions…
NewPython19
  • 75
  • 1
  • 6
4
votes
1 answer

How to set an application icon in Qt

I have some trouble trying to set an icon for my QT application. The icon is named "room.ico" and is on the same directory as the source file. Here is the code : #include #include int main( int argc, char *argv[ ] ) { …
The Beast
  • 1,629
  • 2
  • 29
  • 42
4
votes
3 answers

Qt4: tinting a QIcon

What is the easiest way to apply a color tint to a QIcon in Qt4/PyQt4? I have several monochrome QPixmaps which I'd like to re-color based on the properties of their associated objects.
ChrisB
  • 4,628
  • 7
  • 29
  • 41
3
votes
1 answer

Qt : icon messing the width of QPushButton - Adjusting icon

I currently use the following style-sheet property for a dynamically created QPushButton string mystyle = "QPushButton { border: 1px solid #8f8f91; border-radius: 1px; min-width: 90px; min-height: 18px;}" The QPushButton also has an icon next to…
MistyD
  • 16,373
  • 40
  • 138
  • 240
3
votes
1 answer

Generate PyQt Legend

I'm trying to build myself a simple graphics calculator, as a way of teaching myself PyQt. I'd like the calculator to have a pane which lists all of the equations plotted and shows the line style used. I began with a QListWidget to achieve these…
EddyTheB
  • 3,100
  • 4
  • 23
  • 32
3
votes
1 answer

Changing QIcon size in QStandardItemModel

I am trying to make QTableView/QStandardItemModel with arbitrary sized qIcons. In the MWE below, I have successfully changed the height of a row using a delegate. I can't figure out how to make it use a larger icon size in the larger row. Any…
user2064766
  • 31
  • 1
  • 2
1
2 3 4 5 6 7