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
1
vote
1 answer

Why don't my QIcons show in my QMenu when I run my PyQt application as root?

I have a PyQt4 application I am working on and I have an issue that I can't seem to solve. I have a bunch of QActions that have a valid QIcon set. These QActions are on a QToolBar, as well as a QMenu. The QIcons show on the QToolBar and the QMenu…
1
vote
1 answer

How to add icons to QMenu in Qt Creator?

I have several *.png icon files like new.png, open.png etc. I added these icons to my main menu in the QtCreator as following: Click on corresponding QAction in desgin mode In that actions property window --> QAction --> icon --> Select…
Ralf Wickum
  • 2,850
  • 9
  • 55
  • 103
1
vote
1 answer

Qt: Change the icon in a QListView

Is there a way to change the icon of an element in a QListView after it has been displayed? I can't find a way to do a setData with the DecorationRole (the role used for the icon). The model used is a custom QFileSystemModel, but the default…
user3842408
  • 89
  • 1
  • 10
1
vote
1 answer

Setting and manipulating Icons in QT

I want to add icons in QMainWindow and when i will click that window it should perform some action like popup some window. So what should i use for the icon menu?
Suresh
  • 745
  • 4
  • 11
  • 25
1
vote
0 answers

Can't store QIcon in private class member

I have model inherited from QAbstractItemModel: class Plugin: public QObject { Q_OBJECT public: explicit Plugin(QObject *parent=0); ~Plugin(); const QIcon icon(); void setIcon(const QString &ico); private: QIcon…
Dibo
  • 1,159
  • 17
  • 34
1
vote
1 answer

Qt Animate QPushButton Icon

I would like to animate the size of the QPushButton icon, because when i try to animate whole QPushButton object size, icon is not resizing at all. It seems theres no property "setScaledContents" on QPushButton icon. I tried to use this code for…
SirLanceloaaat
  • 213
  • 9
  • 18
1
vote
1 answer

Derives from QSettings and store QIcon

I tried to store QIcon using class, which derives from QSettings as follows: setValue("fancy_icon", QIcon::fromTheme("document-new")); but I've got an error: QVariant::save: unable to save type 69. And it doesn't work. Surprisingly if I just…
Dejwi
  • 4,393
  • 12
  • 45
  • 74
1
vote
1 answer

Getting favicon.ico into QIcon without using QPixmap

I am trying to get create a QIcon object from a website's favicon.ico file. Since this download doesn't necessarily happen on the GUI thread, I cannot use QPixmap, and so far I have had no luck figuring out how to convert from QImage to QIcon…
Addy
  • 2,414
  • 1
  • 23
  • 43
0
votes
0 answers

How to save a QIcon in a settings.ini using QSettings?

I'm trying to save a QIcon in a settings.ini using QSettings. I'm saving the icon this way: QIcon icon = button->icon(); if (!icon.isNull()) iniSettings->setValue("icon", icon.pixmap(32, 32).toImage()); And trying to load it as: …
Cesar
  • 41
  • 2
  • 5
  • 16
0
votes
1 answer

The main window icon of the app built with pyside6 is not displayed

I have been learning python for 4 months. Started developing a simple app with qtcreator and pyside 6. Main window initialized and launched but got stuck trying to set icon to main window. Tried many various options - nothing works. I work on…
0
votes
0 answers

QIcon not showing..?

I just made below code and added icon with QIcon but not showing the icon. I double checked that png file is in right location. Anyone can let me know the reason..? I made the icon with png file 512x512 pixel. Transparent background. from…
s1mfo
  • 1
  • 2
0
votes
0 answers

Path Problem In Vs Code for Almost every thing including Files in CWD or imported library

Whenever I need to use a file in Vscode whether if it is imported or in the CWD Vscode can not find it unless I enter the file path fully, is there anything that help to use files in current working directory. or when I import something like QIcon I…
X ZEX
  • 1
  • 1
0
votes
1 answer

PyQt5.QIcon Is not showing any icon

I am trying to show the icon in the window bar and this is not simply working. I tried several solutions but still it doesn't work. Any solution for this code? import os from PyQt5.QtCore import * from PyQt5.QtGui import QIcon from PyQt5.QtWidgets…
user19068800
0
votes
1 answer

Use Qicon disabled mode for off state

I have a bunch of checkable QToolbuttons, and I'd like the icons to be 'greyed out' in the unchecked state. I can accomplish this by setting different files for the on/off states in the QIcon. like this: tb = QToolButton() …
mahkitah
  • 562
  • 1
  • 6
  • 19
0
votes
0 answers

How Can I Remove The Blue Tint On The QTreeWidget Item Icon

``` from PyQt5.QtCore import * from PyQt5.QtGui import * from PyQt5.QtWidgets import * from datetime import * import sqlite3 import sys import time import datetime class MyDelegateTreeWidget(QStyledItemDelegate): def __init__(self): …
KaizeL
  • 17
  • 6