Results 1 to 4 of 4

Thread: Issue with icons and static build

  1. #1
    Join Date
    Apr 2012
    Posts
    17
    Thanks
    1
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default 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 **********
    Qt Code:
    1. QT += core gui widgets
    2.  
    3. TARGET = test
    4. TEMPLATE = app
    5.  
    6. SOURCES += main.cpp
    7. HEADERS += mainwindow.h
    8. RESOURCES += \
    9. Images.qrc
    To copy to clipboard, switch view to plain text mode 

    ********** main.c file **********
    Qt Code:
    1. #include "mainwindow.h"
    2. #include <QApplication>
    3.  
    4. int main(int argc, char *argv[])
    5. {
    6. QApplication a(argc, argv);
    7. MainWindow w;
    8. w.show();
    9. return a.exec();
    10. }
    11.  
    12.  
    13. MainWindow::MainWindow(QWidget *parent) :
    14. QMainWindow(parent)
    15. {
    16. Q_INIT_RESOURCE(Images);
    17. tBtn = new QToolButton(this);
    18. tBtn->setIcon(QIcon(":/buttons/arrowUp.ico"));
    19. move(0,0);
    20. }
    21.  
    22. MainWindow::~MainWindow()
    23. {
    24. }
    To copy to clipboard, switch view to plain text mode 

    ********** Images.qrc file **********
    Qt Code:
    1. <RCC>
    2. <qresource prefix="/buttons">
    3. <file>arrowUp.ico</file>
    4. </qresource>
    5. </RCC>
    To copy to clipboard, switch view to plain text mode 

  2. #2
    Join Date
    Mar 2010
    Posts
    86
    Thanks
    11
    Thanked 7 Times in 4 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default 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)

  3. #3
    Join Date
    Apr 2012
    Posts
    17
    Thanks
    1
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default 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.

  4. #4
    Join Date
    Apr 2012
    Posts
    17
    Thanks
    1
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default 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.

Similar Threads

  1. Build static QT + static SSL problem.
    By makzimi in forum Qt Programming
    Replies: 3
    Last Post: 24th April 2012, 00:45
  2. Replies: 3
    Last Post: 1st June 2011, 16:32
  3. Replies: 1
    Last Post: 14th January 2010, 00:35
  4. Moving from QT 4.5 shared build to QT 4.5.2 static build
    By extrakun in forum Qt Programming
    Replies: 0
    Last Post: 26th October 2009, 10:49
  5. Change icons on static QMessageBox
    By manucorrales in forum Qt Programming
    Replies: 1
    Last Post: 22nd July 2006, 20:00

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.