Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt Creator and other tools
  4. QToolBar Icons Not Showing
Forum Updated to NodeBB v4.3 + New Features

QToolBar Icons Not Showing

Scheduled Pinned Locked Moved Solved Qt Creator and other tools
6 Posts 4 Posters 633 Views 2 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Z Offline
    Z Offline
    Zeke
    wrote on last edited by
    #1

    Hi,
    I wrote a small C++ app using Qt Creator with my MacBook Pro. I created a QToolBar and put a couple Actions with Icons on the toolbar. The icons show in QT Creator, but when I run my program, the icons don't appear. The icons are in my resources.qrc file. I checked this file and even edited it to put the full path for one of the icons in it. That didn't make it appear either at runtime.

    So bottomline:

    The QToolBar icons do not appear at runtime.

    Any help or suggest would be greatly appreciated. I am stuck!

    Thanks,
    Zeke

    1 Reply Last reply
    0
    • Z Offline
      Z Offline
      Zeke
      wrote on last edited by
      #6

      I solved this by loading the icons into the actions using an absolute path. I know it isn't pretty, portable, or standard, but it works for me on my computer. The only place this app will ever be used.

      QString openIcon = "absolute path to my icon image";
      ui->actionOpen->setIcon(QIcon(openIcon));
      
      1 Reply Last reply
      0
      • SGaistS Offline
        SGaistS Offline
        SGaist
        Lifetime Qt Champion
        wrote on last edited by SGaist
        #2

        Hi and welcome to devnet,

        Do you mean they do not appear when running your application with Qt Creator or when outside ?
        Can you share the relevant code ?
        Version of Qt ?
        Version of macOS ?

        Interested in AI ? www.idiap.ch
        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

        1 Reply Last reply
        0
        • Z Offline
          Z Offline
          Zeke
          wrote on last edited by
          #3

          Hi SGaist,
          I ran the app within Qt Creator and also standalone. Same results. I am using Qt Creator 15.0.1 and Qt 6.10.0. MACOS Sequoia 15.3.2. I uploaded a section of mainwindow.ui, resources.qrc, and a screenshot of my project directory. Thanks for your help!

          Here is my mainwindow.ui code:

            <widget class="QToolBar" name="toolBar">
             <property name="windowTitle">
              <string>toolBar</string>
             </property>
             <attribute name="toolBarArea">
              <enum>TopToolBarArea</enum>
             </attribute>
             <attribute name="toolBarBreak">
              <bool>false</bool>
             </attribute>
             <addaction name="actionAbout_RSR"/>
             <addaction name="actionOpen"/>
            </widget>
            <action name="actionAbout_RSR">
             <property name="icon">
              <iconset resource="resources.qrc">
               <normaloff>:/images/ToolbarInfo.icns</normaloff>:/images/ToolbarInfo.icns</iconset>
             </property>
             <property name="text">
              <string>About RSR</string>
             </property>
             <property name="iconVisibleInMenu">
              <bool>true</bool>
             </property>
             <property name="shortcutVisibleInContextMenu">
              <bool>true</bool>
             </property>
            </action>
            <action name="actionAbout_Qt">
             <property name="text">
              <string>About Qt</string>
             </property>
            </action>
            <action name="actionOpen">
             <property name="icon">
              <iconset resource="resources.qrc">
               <normaloff>:/images/PicturesFolderIcon.icns</normaloff>:/images/PicturesFolderIcon.icns</iconset>
             </property>
             <property name="text">
              <string>Open...</string>
             </property>
            </action>
          

          And here is my resources.qrc code:
          <widget class="QToolBar" name="toolBar">
          <property name="windowTitle">
          <string>toolBar</string>
          </property>
          <attribute name="toolBarArea">
          <enum>TopToolBarArea</enum>
          </attribute>
          <attribute name="toolBarBreak">
          <bool>false</bool>
          </attribute>
          <addaction name="actionAbout_RSR"/>
          <addaction name="actionOpen"/>
          </widget>
          <action name="actionAbout_RSR">
          <property name="icon">
          <iconset resource="resources.qrc">
          <normaloff>:/images/ToolbarInfo.icns</normaloff>:/images/ToolbarInfo.icns</iconset>
          </property>
          <property name="text">
          <string>About RSR</string>
          </property>
          <property name="iconVisibleInMenu">
          <bool>true</bool>
          </property>
          <property name="shortcutVisibleInContextMenu">
          <bool>true</bool>
          </property>
          </action>
          <action name="actionAbout_Qt">
          <property name="text">
          <string>About Qt</string>
          </property>
          </action>
          <action name="actionOpen">
          <property name="icon">
          <iconset resource="resources.qrc">
          <normaloff>:/images/PicturesFolderIcon.icns</normaloff>:/images/PicturesFolderIcon.icns</iconset>
          </property>
          <property name="text">
          <string>Open...</string>
          </property>
          </action>
          <RCC>
          <qresource prefix="/images">
          <file>Disney.png</file>
          <file>ChrisAndJil.jpg</file>
          <file>wildflowers2.jpg</file>
          <file>camera.jpg</file>
          <file>family-icon.jpg</file>
          <file>snoopy.png</file>
          <file>greenUp.png</file>
          <file>ToolbarInfo.icns</file>
          <file>PicturesFolderIcon.icns</file>
          </qresource>
          </RCC>

          Screenshot 2025-03-13 at 6.31.53 PM.png

          1 Reply Last reply
          0
          • Christian EhrlicherC Offline
            Christian EhrlicherC Offline
            Christian Ehrlicher
            Lifetime Qt Champion
            wrote on last edited by
            #4

            When you deploy your application (with windeployqt, hopefully) make sure that the icons plugin is properly deployed (qico.dll)

            Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
            Visit the Qt Academy at https://academy.qt.io/catalog

            jsulmJ 1 Reply Last reply
            0
            • Christian EhrlicherC Christian Ehrlicher

              When you deploy your application (with windeployqt, hopefully) make sure that the icons plugin is properly deployed (qico.dll)

              jsulmJ Online
              jsulmJ Online
              jsulm
              Lifetime Qt Champion
              wrote on last edited by
              #5

              @Christian-Ehrlicher said in QToolBar Icons Not Showing:

              windeployqt

              macdeployqt in this case

              https://forum.qt.io/topic/113070/qt-code-of-conduct

              1 Reply Last reply
              1
              • Z Offline
                Z Offline
                Zeke
                wrote on last edited by
                #6

                I solved this by loading the icons into the actions using an absolute path. I know it isn't pretty, portable, or standard, but it works for me on my computer. The only place this app will ever be used.

                QString openIcon = "absolute path to my icon image";
                ui->actionOpen->setIcon(QIcon(openIcon));
                
                1 Reply Last reply
                0
                • Z Zeke has marked this topic as solved on

                • Login

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • Users
                • Groups
                • Search
                • Get Qt Extensions
                • Unsolved