Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Qt Icon embedded in Executeable

Tags:

icons

qt

I have some buttons on a tabwidget. These buttons need to have some icon on top of them.

I am aware of QPixmap that will allow me to put an image on top of a button, but I see that these constructors take a filepath as a parameter. I want to avoid dragging icons around in a file after I build. I would like to embed these icons in the executeable somehow, so as to reduce the baggage that I need to lug around in order to make it work.

How can I accomplish this?

I am interested in hearing ways to accomplish my goal of not needing to drag icon files around with the executable; please focus on this aspect if you are confused about some terminology I may have used, as I am still learning Qt.

like image 914
San Jacinto Avatar asked Nov 05 '09 15:11

San Jacinto


People also ask

How set exe icon in Qt?

This can be done using Microsoft Visual Studio: Select File >> New, and choose the Icon File. Note: You need not load the application into the Visual Studio IDE as you are using the icon editor only. Store the ICO file in your application's source code directory, for example, with the name appico.

How do I add an icon to a widget in Qt?

To create a pixmap from the file, we need to first create an image and then convert this image into a pixmap using QPixmap::fromImage(). Once we have the final pixmap, we add it, with its associated mode and state, to the QIcon's set of available pixmaps. previewArea->setIcon(icon);


1 Answers

Of course you can embed icons, images and all other custom resources into your application. Please read The Qt 4's Resource System (or click here for Qt 5)

like image 175
alexkr Avatar answered Sep 22 '22 12:09

alexkr