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

QIcon/QImage memory leak?

I'm facing some memory leaks using QIcon (Qt 4.8.1 with MSVC 2008). This happens with simple QAction (like menu entries, even those generated automatically by Qt Designer) or container items (like QTreeWidgetItem). For example: QTreeWidgetItem…
XDnl
  • 470
  • 3
  • 14
2
votes
0 answers

QPainter.drawText output is blurry

I'm trying to create a system tray icon to display a string ("Hello world!" in the code snippet below) using QPainter's drawText. The problem is that the text is not crisp, and is rather blurry (I have a HiDPI monitor if that's relevant). Here's a…
Blademaster
  • 324
  • 2
  • 15
2
votes
1 answer

QAction's icon doesn't show in QMenu

I had a working program in Qt4. After porting it to Qt5, the QActions' icons no longer show in the QMenu; only the text shows. The icons show ok in the toolbar, but not in the menu. I've already set the app to disable "AA_DontShowIconsInMenus" to…
DrewD
  • 21
  • 3
2
votes
0 answers

Add icon to the right side of a tab in PyQt5

I don't manage to find a way to put an icon to the right side of a tab. By default, PyQt puts it to the left side. What is the code to change this ? Here is what I have for the moment : The red cross is my icon but I don't manage to put it to the…
DigitalRomance
  • 305
  • 2
  • 7
2
votes
1 answer

How to set fixed Icon size that scales with HiDPI in Qt

How can I set Icon size in my application so that it's still scaled when the users uses Screen Scaling? In my application I have a QToolBar in the MainWindow that seems to use an Icon size of 24x24. I have some QToolButton which seem to get an Icon…
Damir Porobic
  • 681
  • 1
  • 8
  • 21
2
votes
1 answer

Centering a QIcon in a QTableWidgetItem in PyQt5

I have a QTableWidget in which some of the QTableWidgetItem's contain a single QIcon (not a button, not clickable, just an image). Can anybody advise me on how to center the icon? I am providing below some sample code which correctly displays the…
bavistr
  • 352
  • 1
  • 10
2
votes
1 answer

Align icon on the right and center the text in a QPushButton

I'm trying to align the icon to the right and center the text in a QPushButton, but I'm not satisfied with the result for now. I would also like the icon to be completely to the right of the QPushButton and not centered with the text. Likewise I…
ekdmekdm
  • 171
  • 1
  • 9
2
votes
1 answer

PySide: how to scale up images in QTableWidget?

I have problem with PySide QTableWidget. I need to add in first column of all rows image preview. I'm trying to add this using QIcon: library_table.insertRow(index) library_table.setItem(index, 1, QTableWidgetItem(file)) image = QIcon(self.sub_ad +…
Websterek
  • 39
  • 5
2
votes
1 answer

how to position the QIcon in the Qt table item?

I want a table cell with text aligned to the left and icon aligned to the right side. But now, im getting both icon and text left aligned, here what i have tried QtTableWidgetItem * item = new QtTableWidgetItem("program"); item -> setIcon(icon); ui…
suruhj
  • 25
  • 5
2
votes
2 answers

Why the icon in QListWidget is displayed only for the first element?

Target: I want the class object inherited from QGraphicsItem to be displayed as an icon in QListWidget. Issue: In the list, the icon is displayed only for the first item. how it looks Tried to redefine the function QIconEngine:: pixmap, put a…
2
votes
2 answers

QIcon with SVG appears black

I need to support high DPI displays with my Qt 5.9.1 application and I'm looking for a solution to scale the QIcons used by the app. I'm currently only targeting Windows 7 and 10. So far, for non-high DPI displays (Windows 7), I used .ico files for…
JPh
  • 536
  • 3
  • 20
2
votes
0 answers

QIcon blurred on Retina iPad Air

I am currently developing an app for iOS with QT 5.7. I am using some buttons which have an QIcon applied. QIcon loads a *.png file and it is assigned to the pushbutton via QIcon::pixmap(). While this is nice looking on my iMac (without retina) on…
dspverden
  • 31
  • 3
2
votes
2 answers

How do I access Awesomefonts in Qt on OpenSuse

I wish to use some of the icons in fontawesome (http://fontawesome.io/icons) in my Qt Application, I have extracted the fontawesome-webfont.ttf file into usr/share/fonts.I tried searching online but could n't find any such examples.This is a sample…
2
votes
2 answers

How to set different icons to different buttons in Qt?

I have a lot of buttons that I want to set an icon to. Moreover, this icon is not the same for each button. I do this just for one of them: QString str=(qApp->applicationDirPath()); str.append("/pic/kb.png"); QPixmap pixmap(str); QIcon…
MHM
  • 261
  • 1
  • 2
  • 15
2
votes
1 answer

QT - How to get QPushButton Active On/Off Icon Name

I would specifically like to get the active on/off name of the icon for the qPushButton. I tried to log first the icon name like on my code but the output was always empty even if I tried to programmatically make an icon, any idea how to solve…
Garlen
  • 426
  • 1
  • 5
  • 17