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

How to set QStyleOptionButton like a checkbox with custom icons

I have a custom Delegate class which inherits from QStyledItemDelegate. In its paint() event, I would like to add QStyleOptionButton which should be checkable. Is it possible? For example, it denotes visibility property with an icon of eye; and when…
vicrucann
  • 1,703
  • 1
  • 24
  • 34
0
votes
1 answer

How to put QImage with gray background inside QIcon?

I'm doing: QIcon(QPixmap::fromImage(img)); and then putting it to QToolButton with setIcon and setIconSize I need to have my img surrounded with gray color inside this icon - how can I implement this? alike there:
cnd
  • 32,616
  • 62
  • 183
  • 313
0
votes
1 answer

QT Custom QStyle for QTabBar and QIcon

I have customize a Qtabbar's QMdiarea to get horizontal tab instead of vertical tab like this : http://www.qtcentre.org/wiki/index.php?title=Customizing_QTabWidget%27s_QTabBar But i want to insert icon in my QTabBar. If I apply my custom style to my…
Zennoi
  • 13
  • 3
0
votes
1 answer

QT - Swapping Icons

I made a simple program to demonstrate my issues with attempting to use the QIcon swap() function. I am trying to swap the icons on two QPushButtons using this function, but it doesnt seem to be working. mainwindow.h #ifndef MAINWINDOW_H #define…
halexh
  • 3,021
  • 3
  • 19
  • 19
0
votes
0 answers

QT4 and shell32.dll - use built-in windows icons

is there any possibility to do something like this in Linux (QIcon::fromTheme("application-exit");) in Windows too? Is there any trick how to make app to have uniform look with actual system and theme? I also don't want to include my own icons, it…
Kovo
  • 434
  • 4
  • 14
0
votes
2 answers

Adding image to QPushButton on Qt

I'm fairly new to C++ in general, so I need a little help with Qt. I'm trying to add an image to a PushButton, and I keep having problems with it. Here is an example of what I have: #include QPushButton *button; button = new…
Connor M
  • 331
  • 3
  • 5
  • 18
0
votes
1 answer

Populate a QListWidget with QImage

I have a QListWidget instance in the middle of my application. I want to populate it with some dynamically created QImage. After reading the manual I have understand that i have to pass through a QIcon object. But.. How can I create a QIcon from a…
nkint
  • 11,513
  • 31
  • 103
  • 174
0
votes
1 answer

PyQt4 - Making a QIcon look active or "pressed down"

I have a QMainWindow with a toolbar that has a bunch of QIcon buttons. Clicking these buttons switches between widgets in a QStackedWidget. Basically, the buttons function as tabs, opening different parts of the program. Now, what I want to do is…
Natsukane
  • 681
  • 1
  • 8
  • 19
0
votes
1 answer

Qt, QWidget, QTabWidget, QTabBar: How to move the text to the bottom of icon?

By default, the text is always on the right-side of the tab icon... What should I do to move the text to the bottom of it ? And is there an option to do icon/text alignment ?? (I'm designing the GUI base on Qt Creator Designer. I'm trying with…
aviit
  • 1,957
  • 1
  • 27
  • 50
0
votes
1 answer

Qt/C++: Icons not showing up when program is running in Kubuntu

I did everything what I need to do: added an icon to resource file initialized resource in main file: Q_INIT_RESOURCE(images); set icon: ui->action_New->setIcon(QIcon(":/images/about_me.png")); but still cant see an image when I compile and run…
Katie
  • 3,517
  • 11
  • 36
  • 49
0
votes
1 answer

strange behaviour while adding QIcon

I am adding a items to listwidget but strangely the first block of if adds icon while the second one doesnt i also checked that the icon is in place in the specified location def addToRenderQueue(self): …
user1176501
0
votes
2 answers

How to get list of application icons which are installed in device with Qt

I am working with Qt application in which I want to create a QListWidget with names of all application installed on device and its icon. So I was unable get all application names and UID of each application from the code in this LINK. But I was also…
Shankar Agarwal
  • 34,573
  • 7
  • 66
  • 64
-1
votes
1 answer

how to use a local image as a Qicon

I want to use githubLogo.svg as a Qicon so I did this:enter image description here But it's not working. enter image description here I don't understand why is not working, I used the quasar doc (https://quasar.dev/vue-components/icon#introduction)…
Astarose
  • 1
  • 2
-1
votes
1 answer

Python PyQt5 load Image for QPushButton on QThread

So I have this UI that loads ALOT of buttons, all with Images, problem is, it takes WAY to long, so I tried putting it into a QThread, I had it working, but there was no speed difference, so I tried a different solution, but now the Thread wont…
JareBear
  • 467
  • 9
  • 27
-1
votes
1 answer

How to retrieve the icon FROM a QPushButton?

QT 5.8.0, OSX 10.12.6 I need to retrieve the image on a QButton in a window. Here's where I'm at: I have a number of QPushButtons in a window. These all have been set to have images in QtDesigner by selecting the images from resources assigned to…
fyngyrz
  • 2,458
  • 2
  • 36
  • 43