Issue with icons and static build
I came across an issue regarding icons and static build.
Consider the following tiny program below.
If it is compiled with a dynamic build the icon in the toolButton is shown.
If it is compiled with static built it is not.
This behavior does not change whether I comment the QT_INIT_RESOURCE or not.
Can anyone suggest a solution so that I can see the icon after a static build also?
I tried using Qt 5.2.1 and MingGW
Thank you.
******* test.pro file **********
Code:
QT += core gui widgets
TARGET = test
TEMPLATE = app
SOURCES += main.cpp
HEADERS += mainwindow.h
RESOURCES += \
Images.qrc
********** main.c file **********
Code:
#include "mainwindow.h"
#include <QApplication>
int main(int argc, char *argv[])
{
MainWindow w;
w.show();
return a.exec();
}
MainWindow
::MainWindow(QWidget *parent
) :{
Q_INIT_RESOURCE(Images);
tBtn
->setIcon
(QIcon(":/buttons/arrowUp.ico"));
move(0,0);
}
MainWindow::~MainWindow()
{
}
********** Images.qrc file **********
Code:
<RCC>
<qresource prefix="/buttons">
<file>arrowUp.ico</file>
</qresource>
</RCC>
Re: Issue with icons and static build
ahhh maybe try tBtn->show();
and #include <QIcon> couldn't hurt
and if you grab the .dll's you need the imageformats folder to be a subdirectory of your application,
including the dico.dll in it
(if you're using windows)
Re: Issue with icons and static build
I will try your suggestions.
When in trouble every suggestion, even those that one does not understand well, must be tried.
but:
- the button IS shown, only the icon is missing
- the icon IS displayed when the program is compiled dynamically (run from Qt creator). Only when static linked the icon is missing.
- if some dll were missing the program would not be linked. Indeed it is linked but somehow Qt "forgets" to link the icons.
I think there is some sort of a bug here, but I'm sure there must be a workaround for this: I cannot believe that people can live with Qt not being able to display icons when programs are statically linked.
Re: Issue with icons and static build
Well,
I've solved this.
I needed to statically link the Qt plugin for icons.
It was just the matter of adding to the .pro file the following row:
QTPLUGIN += qico
Regards.