I've added a QAction
to my QToolBar
in my MainWindow in Qt Designer (using the Qt Creator IDE) and given that Action an icon (done by "Choose File" and selecting my .png located in the same directory as my project and source code). The icon shows up fine in the toolbar in Qt Designer, but does not show when the project is running. I've had similar trouble when choosing the title bar icon on windows. I've never used graphics in Qt before, is there something special I need to do?
Screenshot:
Setting the Application Icon on Windows 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.
Qt supports various compilers, including the GCC C++ compiler, the Visual Studio suite, PHP via an extension for PHP5, and has extensive internationalization support. Qt also provides Qt Quick, that includes a declarative scripting language called QML that allows using JavaScript to provide the logic.
I found myself doing all the right stuff, adding a qrc file and placing my icons there. When I run the program no deal. Turn out I was forgetting to run qmake:
Everytime you change something in the .pro file you need to run qmake again. Creating a resource file implicitly adds argunments to the .pro file, so you need to do it.
Hope it helps other people out there.
Did you make a QRC file (that is, Qt's equivalent of a resource file?) If not, that would explain what you're seeing. The icons will show up in the creator, but not in the final compiled executable. Have a look at this:
http://doc.qt.io/qt-5/resources.html
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With