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

Icon size on QComboBox's popup list

I'm trying to make a simple QComboBox with a few color options. The easiest way I found so far was to make a QPixmap for each item, fill it with a color and use it as the item's icon: this->colorComboBox = new…
chapulina
  • 45
  • 2
  • 7
2
votes
1 answer

scaled QIcon in child thread

I need to load big amount of imgs into QIcons (all work is ruled with a child thread). if I write: QIcon(filename) - it'll load all file. and after 150 or 200 files have been loaded, there is no free RAM. at first I tried to use QImage and scale it:…
Illia Levandovskyi
  • 1,228
  • 1
  • 11
  • 20
2
votes
1 answer

qdatawidgetmapper for displaying qicons?

I'm currently trying to create a widget which allows me to display properties of a given tool. I have a model containing all tools, and what i would like to create is basically a combobox which allows to select one tool and the tools properties are…
Donny
  • 549
  • 2
  • 10
  • 24
1
vote
1 answer

How to make a QIcon switch appearance without resetting it on the widget?

Now that dark mode has finally come to Windows with Qt 6.5, I noticed that a lot of my icons don't look too well on a dark background. So I'd like to use different icons for light and dark mode. And, to make things difficult, have the icons change…
mahkitah
  • 562
  • 1
  • 6
  • 19
1
vote
1 answer

QIcon not showing in QToolBar

I'm a beginner in Qt, currently reading this : https://zetcode.com/gui/qt5/menusandtoolbars/ When I declare QActions in a QToolBar, the QPixmap objects (turned into QIcons) are not showing : No icons, only text However, the QPixmap images are…
1
vote
0 answers

Icon not showing in QListWidgetItem

Icons are not showing in my QListWidgetItems. Edit 2: Turns out you can't use absoulte path. You must use relative path. But why is this the case? Minimum reproducible example: import json import os import sys from math import floor from PyQt5…
Karan
  • 25
  • 7
1
vote
1 answer

Remove icon from window

I've discovered that if I remove all flags from a QDialog, and set Windows flags to QtCore.Qt.CustomizeWindowHint and QtCore.Qt.WindowTitleHint, the icon disappears, but also the close button. Unfortunately, if I add the flag of…
Lavínia Beghini
  • 165
  • 1
  • 11
1
vote
1 answer

How to get better image quality on QPixmaps even after KeepAspectRatio and SmoothTransition

I am making a desktop application using the PySide2 implementation of Qt. Something this application needs to do is display high quality images to the user, however when I use the QPixmap class, images are always at significantly lower quality that…
Brown Philip
  • 219
  • 1
  • 3
  • 12
1
vote
1 answer

Why python not show in path icon?

I wrote below code import sys,time from PyQt5.QtGui import * from PyQt5.QtWidgets import * app = QApplication(sys.argv) sys.path.append(r"C:\Users\hpaalm\Desktop") a=QPushButton() a.setIcon(QIcon('1.png')) a.show() app.exec_() when i run it in…
hpaalm
  • 65
  • 10
1
vote
1 answer

How to make size of button in the LineEdit smaller?

I made the X button in the LineEdit, when i click on this button, the LineEdit is clear. But with my method, the X button looks a little big and not beautiful, I need to make it smaller. How I can do it? myLineEdit = new…
songvan
  • 369
  • 5
  • 21
1
vote
1 answer

Convert jpeg image to thumbnail image in Qt

A QImage needs to be finally shown as a thumbnail image in a QLabel. In between it's serialized in QByteArray and sent over the network. So, can we convert the QImage to QByteArray for thumbnail? Basically I want to avoid the QImage::scale() method…
Sayan Bera
  • 135
  • 2
  • 16
1
vote
1 answer

PyQt5 5.9 , setWindowIcon( QIcon(*WEB_LINK*) )

Hi, I have an issue with my PyQt5 setWindowIcon. When I try to set my window icon from a local image, it works perfectly. But when I try to put a online link like: setWindowIcon(…
Pixsa
  • 571
  • 6
  • 16
1
vote
0 answers

Qt : Changing color of an icon used through FontAwesome in Qt when accessed through Unicode.

I have written a code to print an Icon accessed from FontAwesome installed in the system. I would like to change the color for the Icon printed on the Screen.I have tried using QPixmap and QIcon,but to no avail.Attached the output : #include…
1
vote
2 answers

Using QIcon does not display the image

I'm trying to learn PyQt. While going over a tutorial to get the basics I've encountered a problem with QIcon. The following code is supposed to create a simple window with an icon from an image called 'web.png': import os import sys import…
Ne_Plus_Ultra
  • 191
  • 2
  • 13
1
vote
1 answer

Create QIcon from resources.qrc file

I have a resources.qrc file that looks like this: base_aerial.png base_alkis.png adr.png gps_coord.png road.png
Jochen Schwarze
  • 292
  • 6
  • 27