Home > Back-end >  Qt/C : Icons not showing up when program is run from explorer
Qt/C : Icons not showing up when program is run from explorer

Time:07-20

I looked at all similar questions, but there everything was decided by the fact that I kind of did it anyway. In general, I added icons in .ico format to some buttons and windows. When I run from QTCreator everything works fine, but even if I run Exe directly from the folder, the icons disappear. I am aware that the dlls should be reported to the folder, I added them using windeploykit. I also reported the icons folder in the same way as I have it in the project. This did not help, only the icon added to RC_ICONS is shown.

release folder

.pro file:


greaterThan(QT_MAJOR_VERSION, 4): QT  = widgets

CONFIG  = c  17

# You can make your code fail to compile if it uses deprecated APIs.
# In order to do so, uncomment the following line.
#DEFINES  = QT_DISABLE_DEPRECATED_BEFORE=0x060000    # disables all the APIs deprecated before Qt 6.0.0

SOURCES  = \
    ADDStudentWindow.cpp \
    AVLTreeController.cpp \
    AVLWindow.cpp \
    ListBestController.cpp \
    ListController.cpp \
    ListWindow.cpp \
    Student.cpp \
    StudentController.cpp \
    main.cpp \
    MainWindow.cpp

HEADERS  = \
    ADDStudentWindow.h \
    AVLTree.h \
    AVLTreeController.h \
    AVLWindow.h \
    List.h \
    ListBestController.h \
    ListController.h \
    ListWindow.h \
    MainWindow.h \
    Student.h \
    StudentController.h

FORMS  = \
    ADDStudentWindow.ui \
    AVLWindow.ui \
    ListWindow.ui \
    MainWindow.ui

# Default rules for deployment.
qnx: target.path = /tmp/$${TARGET}/bin
else: unix:!android: target.path = /opt/$${TARGET}/bin
!isEmpty(target.path): INSTALLS  = target

win32:RC_ICONS  = icons/graduated.ico
RESOURCES  = \
    resources.qrc

Run from QT Creator:

Run from explorer:

I also tried to report qrc and res files (respectively from the project folder and from the compiled build folder), but this did not help

CodePudding user response:

Make sure you added icons to buttons using "Choose resource..." not "Choose File..." in designer (QtCreator).

Try adding qt.conf to executable directory with content:

[Paths]
plugins = .

CodePudding user response:

It could be an encoding related issue. Does your path contain any Russian characters? If it does, I recommend that you change the file path with only English characters.

  •  Tags:  
  • c qt
  • Related