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 **********
QT += core gui widgets
TARGET = test
TEMPLATE = app
SOURCES += main.cpp
HEADERS += mainwindow.h
RESOURCES += \
Images.qrc
QT += core gui widgets
TARGET = test
TEMPLATE = app
SOURCES += main.cpp
HEADERS += mainwindow.h
RESOURCES += \
Images.qrc
To copy to clipboard, switch view to plain text mode
********** main.c file **********
#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()
{
}
#include "mainwindow.h"
#include <QApplication>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
MainWindow w;
w.show();
return a.exec();
}
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent)
{
Q_INIT_RESOURCE(Images);
tBtn = new QToolButton(this);
tBtn->setIcon(QIcon(":/buttons/arrowUp.ico"));
move(0,0);
}
MainWindow::~MainWindow()
{
}
To copy to clipboard, switch view to plain text mode
********** Images.qrc file **********
<RCC>
<qresource prefix="/buttons">
<file>arrowUp.ico</file>
</qresource>
</RCC>
<RCC>
<qresource prefix="/buttons">
<file>arrowUp.ico</file>
</qresource>
</RCC>
To copy to clipboard, switch view to plain text mode
Bookmarks