A
A
Alexander Sharomet2014-08-20 10:43:56
Programming
Alexander Sharomet, 2014-08-20 10:43:56

Why are icons not showing in qt Creator?

Hello.
In qt Creator I created a resource file and put icons there but when compiling they don't show
up Here is the qrc file

<RCC>
    <qresource prefix="/icons">
        <file>images/delete.ico</file>
        <file>images/folder.ico</file>
        <file>images/plus.ico</file>
        <file>images/save.ico</file>
        <file>images/tick.ico</file>
    </qresource>
</RCC>

and ui file
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
 <class>MainWindow</class>
 <widget class="QMainWindow" name="MainWindow">
  <property name="geometry">
   <rect>
    <x>0</x>
    <y>0</y>
    <width>485</width>
    <height>380</height>
   </rect>
  </property>
  <property name="windowTitle">
   <string>MainWindow</string>
  </property>
  <property name="iconSize">
   <size>
    <width>20</width>
    <height>20</height>
   </size>
  </property>
  <property name="toolButtonStyle">
   <enum>Qt::ToolButtonIconOnly</enum>
  </property>
  <widget class="QWidget" name="centralWidget"/>
  <widget class="QMenuBar" name="menuBar">
   <property name="geometry">
    <rect>
     <x>0</x>
     <y>0</y>
     <width>485</width>
     <height>18</height>
    </rect>
   </property>
   <widget class="QMenu" name="menu">
    <property name="title">
     <string>Файл</string>
    </property>
    <addaction name="action"/>
    <addaction name="action_2"/>
    <addaction name="action_3"/>
    <addaction name="action_4"/>
    <addaction name="action_5"/>
   </widget>
   <widget class="QMenu" name="menu_2">
    <property name="title">
     <string>Редактировать</string>
    </property>
    <addaction name="action_6"/>
    <addaction name="action_7"/>
   </widget>
   <addaction name="menu"/>
   <addaction name="menu_2"/>
  </widget>
  <widget class="QToolBar" name="mainToolBar">
   <property name="movable">
    <bool>false</bool>
   </property>
   <property name="toolButtonStyle">
    <enum>Qt::ToolButtonIconOnly</enum>
   </property>
   <attribute name="toolBarArea">
    <enum>TopToolBarArea</enum>
   </attribute>
   <attribute name="toolBarBreak">
    <bool>false</bool>
   </attribute>
   <addaction name="action"/>
   <addaction name="action_2"/>
   <addaction name="action_3"/>
   <addaction name="action_5"/>
  </widget>
  <widget class="QStatusBar" name="statusBar"/>
  <action name="action">
   <property name="icon">
    <iconset resource="resurses.qrc">
     <normaloff>:/icons/images/plus.ico</normaloff>:/icons/images/plus.ico</iconset>
   </property>
   <property name="text">
    <string>Новый</string>
   </property>
   <property name="shortcut">
    <string>Ctrl+N</string>
   </property>
  </action>
  <action name="action_2">
   <property name="icon">
    <iconset resource="resurses.qrc">
     <normaloff>:/icons/images/folder.ico</normaloff>:/icons/images/folder.ico</iconset>
   </property>
   <property name="text">
    <string>Открыть</string>
   </property>
   <property name="shortcut">
    <string>Ctrl+O</string>
   </property>
  </action>
  <action name="action_3">
   <property name="icon">
    <iconset resource="resurses.qrc">
     <normaloff>:/icons/images/tick.ico</normaloff>:/icons/images/tick.ico</iconset>
   </property>
   <property name="text">
    <string>Сохранить</string>
   </property>
   <property name="shortcut">
    <string>Ctrl+S</string>
   </property>
  </action>
  <action name="action_4">
   <property name="icon">
    <iconset resource="resurses.qrc">
     <normaloff>:/icons/images/save.ico</normaloff>:/icons/images/save.ico</iconset>
   </property>
   <property name="text">
    <string>Сохранить как</string>
   </property>
   <property name="shortcut">
    <string>Ctrl+Shift+S</string>
   </property>
  </action>
  <action name="action_5">
   <property name="icon">
    <iconset resource="resurses.qrc">
     <normaloff>:/icons/images/delete.ico</normaloff>:/icons/images/delete.ico</iconset>
   </property>
   <property name="text">
    <string>Закрыть</string>
   </property>
   <property name="shortcut">
    <string>Ctrl+W</string>
   </property>
  </action>
  <action name="action_6">
   <property name="text">
    <string>Копировать</string>
   </property>
  </action>
  <action name="action_7">
   <property name="text">
    <string>Вставить</string>
   </property>
  </action>
 </widget>
 <layoutdefault spacing="6" margin="11"/>
 <resources>
  <include location="resurses.qrc"/>
 </resources>
 <connections/>
</ui>

What could be wrong?
And one more question when running an exe file, it requires libraries like QtWidgetsd.dll, I can connect them, but if I want to transfer the program to someone who does not have these libraries, what should I do? Is it possible to compile to one file along with libraries? Or should I manually transfer the libraries and distribute with them?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
E
EXL, 2014-08-20
@sharomet

What could be wrong?

It's so hard to say. Can you provide a minimally compiled version of the source code of the program with a demonstration of this problem? In other words, lay out such an archive with source code, icons and project files, where this problem will manifest itself and the project can be built on another machine.
Offhand, I can assume that the problem is that you are using the ".ico" format for icons. Try with icons in png format.
The dependency on QtWidgets d .dll says first of all that you are using the Debug version of your application to distribute. This entails huge risks and problems, for example, anyone familiar with the debugger can get the source code of your program, and the size of the application grows by several hundred megabytes. Therefore, compile the program in Release (Ctrl+T -> Release).
Exactly. But only the release versions of the libraries and your application, this is within 50 MB for Qt5 (libicu is already very fat ) and 20 MB for Qt4.
Possibly, but somewhat tricky, since Qt only distributes dynamic versions of its libraries. Therefore, you will first need to build a static version of Qt (possibly throwing out libicu), and then build your program with static Qt and libgcc/libstdc++/libwinthread(libpthread). Thus, the size of the program can be reduced to 3-6 MB (if you still use upx ). But it should be remembered that with static linking the issue of licensing is very opaque and in addition, QtWebkit cannot be compiled statically. Therefore, if your application uses QtWebkit, you can forget about static linking.

A
Alexander Sharomet, 2014-08-20
@sharomet

www.ex.ua/196341105639
Here is a project, well, just a frame with icons)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question