Important: Please read the Qt Code of Conduct -

Able to add image file in Qt Design, but image not visible at runtime. Bug?

  • Hi, I'm not a programmer and is new to Qt, checking out if Qt is suitable for GUI design.
    Using free Qt Creator 4.8.1 (based on Qt 5.12.1), on Win 10.

    I can add a PNG image of a wrench, pls see screenshot below.

    Problem is during Runtime, it is not visible.

    I read on other posts to try this "Clean, Run qmake, Run". It didn't work for me.

    I saw another post about adding image file as Resource, so I added Resource.

    Then I try to add the image as a Resource, using "Choose Resource" option (see screenshot below). When I clicked on "Choose Resource", the program freezes, all buttons becomes non interactive. I have to press ESC for the program to "snap out of it." So this is an dead end for me.

    Another post solve this problem by adding the image via code. So I tried it.

    #include "mainwindow.h"
    #include "ui_mainwindow.h"
    #include <QPixmap>
    MainWindow::MainWindow(QWidget *parent) :
        ui(new Ui::MainWindow)
        QPixmap pix (":/Img/Img/Wrench.png");
        delete ui;

    While this method is able to display the wrench image at runtime (see screenshot below)

    It does not display the wrench in Qt Design view (see screenshot below). I need it to be visible here, to get a overall view of how the GUI would look like, to arrange the other components.


    Any ideas on how to insert PNG images, preferably in Qt Design, such that it is visible in Qt Design and Runtime?

    This problem is driving me crazy, there seems to be no easy way to insert an image?


  • Lifetime Qt Champion

    @Thug On what platform are you? What is QtCreator version? For me "Choose Resource..." works as expected (Windows 7, QtCreator 4.7.0).

  • Hi jsulm,

    I'm using free Qt Creator 4.8.1, based on Qt 5.12.1, Win 10 Pro.

    My project is a "Qt Widget App" pls see screen below for the option I selected when creating the program.



  • Lifetime Qt Champion

    @Thug Did you check QtCreator bug tracker to see whether this is a known issue? Did you try to disable antivirus software?

  • Lifetime Qt Champion


    Might be a silly question but are you sure your .qrc file is compiled ?

  • Hi @jsulm , I tried disabling McAfee, the "Add Resource" option still freezes. The bug tracker does not seem to show this bug.

    @SGaist , are you refering to "Clean project, Run Qmake, Run project" in QT Creator? If yes, I have already tried it. Or do you mean compile qrc via command prompt? How do I select "Add Resource" in command prompt?

    I remember the "Add Resource" working, not freezing up 4 days ago when I first installed QT. I did not install anything new nor did any settings since then.

  • @Thug
    You can just edit the .pro file and add the line
    RESOURCES += file.qrc
    where "file" is the name of your resource file.
    As always, when changing the .pro file, make sure that you do a clean/qmake/build cycle.

  • Hi, @mranger90 the .pro file already included the .qrc line (pls see screenshot below).


    A copy of the zipped project file is at:

  • I ran that project on an Ubuntu 18.04 system using Qt 5.12.0
    With no modifications, the application built and ran but the wrench was not visible.
    In designer mode, the path to the wrench was to my disk - i.e. /home/joem/SG_GU16/Img/Wrench.png.
    I changed it to point to the resource entry ":/Res/Img/Wrench.png" in the QLabel/pixmap tab for label_2.
    Clean/qmake/rebuild/run and the wrench appears.

  • @mranger90 , may I ask how do you change the path in Designer mode?

    I only see the path
    when I mouseover the "wrench.png" in the pixmap tab.

    Did you select "Choose Resource" or "Choose file"?
    I selected "Choose file". When I select "Choose Resource" the program freezes like it is looking for something, I need to press ESC to unfreeze it.

  • There are a couple of ways.
    the "..." button should give you the option.
    or the DownArrow will allow you to choose a resource.
    Since the png is already in the resource file, this should work.

  • Lifetime Qt Champion

    Its not the project it self as it seems to work with same compiler and Qt version.
    alt text

    Have not heard it freezing before when trying to open the resource browse window.
    very odd.

  • Run qmake after adding Image to Resource file

  • @mrjj oic, then it might be my computer's settings or background programs.

Log in to reply