Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Icons from resource file not showing

Icons from resource file not showing

Scheduled Pinned Locked Moved Solved General and Desktop
11 Posts 4 Posters 7.6k Views
  • 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.
  • V Offline
    V Offline
    Vinod Kuntoji
    wrote on 15 Nov 2017, 07:06 last edited by
    #2

    @saber

    Delete your build folder. Clean your project, qmake and build and then run your project.

    C++, Qt, Qt Quick Developer,
    PthinkS, Bangalore

    1 Reply Last reply
    1
    • S Offline
      S Offline
      saber
      wrote on 15 Nov 2017, 07:10 last edited by saber
      #3

      I did it .but no change.
      I think it is in code to select the icon from theme.
      the app is "lximage-qt"

      1 Reply Last reply
      0
      • V Offline
        V Offline
        Vinod Kuntoji
        wrote on 15 Nov 2017, 10:39 last edited by Vinod Kuntoji
        #4

        @saber ,
        Show me your code

        C++, Qt, Qt Quick Developer,
        PthinkS, Bangalore

        S 1 Reply Last reply 15 Nov 2017, 12:46
        0
        • V Vinod Kuntoji
          15 Nov 2017, 10:39

          @saber ,
          Show me your code

          S Offline
          S Offline
          saber
          wrote on 15 Nov 2017, 12:46 last edited by saber
          #5

          @Vinod-Kuntoji
          thanks for help.
          as a new user in the forum ,i can't upload a zip folder.
          here is the cmake file of it.
          https://forum.qt.io/topic/85016/convert-cmake-file-to-qmake

          and here is the original code.from github
          https://github.com/lxde/lximage-qt

          1 Reply Last reply
          0
          • S Offline
            S Offline
            SGaist
            Lifetime Qt Champion
            wrote on 15 Nov 2017, 21:00 last edited by
            #6

            Hi,

            Please show the content of your .qrc file and the part of the code where you load the icons.

            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
            • S Offline
              S Offline
              saber
              wrote on 16 Nov 2017, 03:26 last edited by saber
              #7

              Here is the qrc file
              0_1510802396487_ooopppp.png

              I use this code first

                QPixmap iu("<:/icons/before.png>");
                 ui.cNext->setIcon(iu);
              

              But not showing the icon.
              so i apply the icons from designer
              and also see the output .the icon is not showing in after build.

              0_1510804112720_yyyyyy.png
              thanks.

              J 1 Reply Last reply 16 Nov 2017, 03:57
              0
              • S saber
                16 Nov 2017, 03:26

                Here is the qrc file
                0_1510802396487_ooopppp.png

                I use this code first

                  QPixmap iu("<:/icons/before.png>");
                   ui.cNext->setIcon(iu);
                

                But not showing the icon.
                so i apply the icons from designer
                and also see the output .the icon is not showing in after build.

                0_1510804112720_yyyyyy.png
                thanks.

                J Offline
                J Offline
                joeQ
                wrote on 16 Nov 2017, 03:57 last edited by
                #8

                @saber hi,friend.welcome.

                try following snippet:

                ui->pushButton->setIcon(QIcon(":/icons/left.ico"));
                

                or

                ui->pushButton->setIcon(QIcon("qrc:/icons/left.ico"));
                

                Just do it!

                1 Reply Last reply
                1
                • S Offline
                  S Offline
                  saber
                  wrote on 16 Nov 2017, 04:08 last edited by
                  #9

                  as i am using qt 5 i used
                  ui.cPrevious->setIcon(QIcon("qrc:/icons/left.ico"));

                  but no result.I don't understand .It should work with code and designer.
                  i think writer of this code made something to take only select the icone from system theme.

                  0_1510805074671_eeee.png

                  J 1 Reply Last reply 16 Nov 2017, 05:27
                  0
                  • S saber
                    16 Nov 2017, 04:08

                    as i am using qt 5 i used
                    ui.cPrevious->setIcon(QIcon("qrc:/icons/left.ico"));

                    but no result.I don't understand .It should work with code and designer.
                    i think writer of this code made something to take only select the icone from system theme.

                    0_1510805074671_eeee.png

                    J Offline
                    J Offline
                    joeQ
                    wrote on 16 Nov 2017, 05:27 last edited by joeQ
                    #10

                    @saber hi, you use cmake. maybe some error in cmake. like source path not set right.

                    if use qmake, my snippet code is ok. you can check the the path in cmake.

                    or To try the absolute path. like following snippet:

                    QPixmap pix;
                    if(pix.load("absolute icon path")){
                        qDebug("icon load ok");
                        QIcon ico(pix);
                        ui->btn->setIcon(ico);
                    }
                    

                    Just do it!

                    S 1 Reply Last reply 16 Nov 2017, 08:01
                    0
                    • J joeQ
                      16 Nov 2017, 05:27

                      @saber hi, you use cmake. maybe some error in cmake. like source path not set right.

                      if use qmake, my snippet code is ok. you can check the the path in cmake.

                      or To try the absolute path. like following snippet:

                      QPixmap pix;
                      if(pix.load("absolute icon path")){
                          qDebug("icon load ok");
                          QIcon ico(pix);
                          ui->btn->setIcon(ico);
                      }
                      
                      S Offline
                      S Offline
                      saber
                      wrote on 16 Nov 2017, 08:01 last edited by saber
                      #11

                      @joeQ
                      nothing.
                      please can u see my post to convert it cmake file to qmake.
                      i think it will solve the problem.
                      https://forum.qt.io/topic/85016/convert-cmake-file-to-qmake

                      1 Reply Last reply
                      1

                      11/11

                      16 Nov 2017, 08:01

                      • Login

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