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. Qt resource not showing up in static build...
Forum Updated to NodeBB v4.3 + New Features

Qt resource not showing up in static build...

Scheduled Pinned Locked Moved Solved General and Desktop
42 Posts 5 Posters 14.9k Views 4 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.
  • mrjjM mrjj

    @mzimmers
    Hi
    You mean when you produce a static linked .exe ( with our own static compiled Qt) ( not the same as release mode vs debug mode )
    the compiled in qres file does not work?

    And you have it in the project like ?
    alt text

    mzimmersM Offline
    mzimmersM Offline
    mzimmers
    wrote on last edited by
    #5

    @mrjj yes on both counts. I am getting an error message at runtime:

    QPixmap::scaled: Pixmap is a null pixmap

    Here's the code I use to display it:

        QPixmap logo(":/logos/logo1color.svg"); // .svg file created from .png file with http://www.autotracer.org/
        QSize logoSize = ui->logoLabel->size();
        ui->logoLabel->setPixmap(logo.scaled(logoSize, Qt::KeepAspectRatio, Qt::SmoothTransformation));
    

    And again, it's working when built for debug.

    mrjjM kshegunovK 2 Replies Last reply
    0
    • mzimmersM mzimmers

      @mrjj yes on both counts. I am getting an error message at runtime:

      QPixmap::scaled: Pixmap is a null pixmap

      Here's the code I use to display it:

          QPixmap logo(":/logos/logo1color.svg"); // .svg file created from .png file with http://www.autotracer.org/
          QSize logoSize = ui->logoLabel->size();
          ui->logoLabel->setPixmap(logo.scaled(logoSize, Qt::KeepAspectRatio, Qt::SmoothTransformation));
      

      And again, it's working when built for debug.

      mrjjM Offline
      mrjjM Offline
      mrjj
      Lifetime Qt Champion
      wrote on last edited by
      #6

      @mzimmers
      Hi, svg is a normally plugin. maybe it was not compiled in ?
      Did you try with a png or a more native image?

      mzimmersM 1 Reply Last reply
      0
      • mzimmersM mzimmers

        @mrjj yes on both counts. I am getting an error message at runtime:

        QPixmap::scaled: Pixmap is a null pixmap

        Here's the code I use to display it:

            QPixmap logo(":/logos/logo1color.svg"); // .svg file created from .png file with http://www.autotracer.org/
            QSize logoSize = ui->logoLabel->size();
            ui->logoLabel->setPixmap(logo.scaled(logoSize, Qt::KeepAspectRatio, Qt::SmoothTransformation));
        

        And again, it's working when built for debug.

        kshegunovK Offline
        kshegunovK Offline
        kshegunov
        Moderators
        wrote on last edited by
        #7

        Can you show your project's file structure? It probably is a path issue (difference) between the release and debug builds.

        Read and abide by the Qt Code of Conduct

        1 Reply Last reply
        1
        • mrjjM Offline
          mrjjM Offline
          mrjj
          Lifetime Qt Champion
          wrote on last edited by
          #8

          Also to be clear.
          It does work in statically linked debug version but not in a
          statically linked release version?
          That is odd.
          When you made your statically linkable Qt, you did use release mode?

          mzimmersM 1 Reply Last reply
          0
          • mrjjM mrjj

            @mzimmers
            Hi, svg is a normally plugin. maybe it was not compiled in ?
            Did you try with a png or a more native image?

            mzimmersM Offline
            mzimmersM Offline
            mzimmers
            wrote on last edited by
            #9

            @mrjj yes, I tried other formats...they looked terrible so I went to .svg.

            @kshegunov: project file layout is entirely flat...do I need a subdirectory called /logos?

            1 Reply Last reply
            0
            • mrjjM mrjj

              Also to be clear.
              It does work in statically linked debug version but not in a
              statically linked release version?
              That is odd.
              When you made your statically linkable Qt, you did use release mode?

              mzimmersM Offline
              mzimmersM Offline
              mzimmers
              wrote on last edited by
              #10

              @mrjj not quite: it works in dynamic/debug, but not in static/release. I haven't tried the other permutations yet.

              kshegunovK 1 Reply Last reply
              0
              • mzimmersM mzimmers

                @mrjj not quite: it works in dynamic/debug, but not in static/release. I haven't tried the other permutations yet.

                kshegunovK Offline
                kshegunovK Offline
                kshegunov
                Moderators
                wrote on last edited by kshegunov
                #11

                Aha! So your debug is in fact dynamically linked. Then do the manual resource initialization as @SGaist hinted!

                Read and abide by the Qt Code of Conduct

                mzimmersM 1 Reply Last reply
                0
                • kshegunovK kshegunov

                  Aha! So your debug is in fact dynamically linked. Then do the manual resource initialization as @SGaist hinted!

                  mzimmersM Offline
                  mzimmersM Offline
                  mzimmers
                  wrote on last edited by
                  #12

                  @kshegunov sorry - I thought I'd made that clear in my OP.

                  I've added this line to my main (my resource file is called "resources.qrc"):

                      Q_INIT_RESOURCE(resources);
                  

                  Still doesn't show, and I'm getting that null pixmap error.

                  1 Reply Last reply
                  0
                  • SGaistS Offline
                    SGaistS Offline
                    SGaist
                    Lifetime Qt Champion
                    wrote on last edited by
                    #13

                    Do you have several resources named like that ?

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

                    mzimmersM 1 Reply Last reply
                    0
                    • SGaistS SGaist

                      Do you have several resources named like that ?

                      mzimmersM Offline
                      mzimmersM Offline
                      mzimmers
                      wrote on last edited by
                      #14

                      @SGaist I'm not sure what you mean by "named like that," but I only have one .qrc file, and it only has two files in it.

                      kshegunovK 1 Reply Last reply
                      0
                      • mzimmersM mzimmers

                        @SGaist I'm not sure what you mean by "named like that," but I only have one .qrc file, and it only has two files in it.

                        kshegunovK Offline
                        kshegunovK Offline
                        kshegunov
                        Moderators
                        wrote on last edited by
                        #15

                        Okay, can you grab a screenshot from the resource editor? Unless that path is an alias, then you need to put the image into that folder under the project. I personally always alias the things because it feels quite clumsy otherwise ...

                        Read and abide by the Qt Code of Conduct

                        1 Reply Last reply
                        0
                        • mzimmersM Offline
                          mzimmersM Offline
                          mzimmers
                          wrote on last edited by mzimmers
                          #16

                          So I need a subdirectory in my source folder? I'll try that.

                          0_1508880996044_resource.PNG

                          EDIT: just moved logo to a subfolder, rebuilt and now I'm getting an error:

                          [release/qrc_resources.cpp] Error 1

                          So I deleted the moved file and re-added it. Still getting the null pixmap error.

                          kshegunovK 1 Reply Last reply
                          0
                          • mzimmersM mzimmers

                            So I need a subdirectory in my source folder? I'll try that.

                            0_1508880996044_resource.PNG

                            EDIT: just moved logo to a subfolder, rebuilt and now I'm getting an error:

                            [release/qrc_resources.cpp] Error 1

                            So I deleted the moved file and re-added it. Still getting the null pixmap error.

                            kshegunovK Offline
                            kshegunovK Offline
                            kshegunov
                            Moderators
                            wrote on last edited by
                            #17

                            @mzimmers said in Qt resource not showing up in static build...:

                            just moved logo to a subfolder, rebuilt and now I'm getting an error:

                            Not any subfolder, looking at the screenshot you need a folder called logos under your project root. Then readd the file and I think it should work.

                            Read and abide by the Qt Code of Conduct

                            mzimmersM 1 Reply Last reply
                            0
                            • kshegunovK kshegunov

                              @mzimmers said in Qt resource not showing up in static build...:

                              just moved logo to a subfolder, rebuilt and now I'm getting an error:

                              Not any subfolder, looking at the screenshot you need a folder called logos under your project root. Then readd the file and I think it should work.

                              mzimmersM Offline
                              mzimmersM Offline
                              mzimmers
                              wrote on last edited by mzimmers
                              #18

                              @kshegunov no joy.

                              0_1508882322220_folder.PNG
                              EDIT: put some text in here to separate the pics.
                              0_1508882354954_qt.PNG

                              But at least now it's missing from both the debug and release versions...

                              kshegunovK 1 Reply Last reply
                              0
                              • mzimmersM mzimmers

                                @kshegunov no joy.

                                0_1508882322220_folder.PNG
                                EDIT: put some text in here to separate the pics.
                                0_1508882354954_qt.PNG

                                But at least now it's missing from both the debug and release versions...

                                kshegunovK Offline
                                kshegunovK Offline
                                kshegunov
                                Moderators
                                wrote on last edited by
                                #19

                                But now your resource tree looks funny, you have two folders named "logos" there ...?

                                Read and abide by the Qt Code of Conduct

                                1 Reply Last reply
                                0
                                • mzimmersM Offline
                                  mzimmersM Offline
                                  mzimmers
                                  wrote on last edited by
                                  #20

                                  OK, I obviously don't know what's going on here. The resource editor requires me to add a prefix before I can add a file. When I add the file, if it's in a subdirectory, that gets prepended to the file name. This is why you're seeing what appears to be two levels of folders.

                                  I don't know how to do this differently.

                                  kshegunovK 1 Reply Last reply
                                  0
                                  • mzimmersM mzimmers

                                    OK, I obviously don't know what's going on here. The resource editor requires me to add a prefix before I can add a file. When I add the file, if it's in a subdirectory, that gets prepended to the file name. This is why you're seeing what appears to be two levels of folders.

                                    I don't know how to do this differently.

                                    kshegunovK Offline
                                    kshegunovK Offline
                                    kshegunov
                                    Moderators
                                    wrote on last edited by
                                    #21

                                    Ah, okay. That's why I'm saying it's damn clumsy. Add only a / as prefix and then add your file. It should fix the double folder thing.

                                    Read and abide by the Qt Code of Conduct

                                    mzimmersM 1 Reply Last reply
                                    0
                                    • kshegunovK kshegunov

                                      Ah, okay. That's why I'm saying it's damn clumsy. Add only a / as prefix and then add your file. It should fix the double folder thing.

                                      mzimmersM Offline
                                      mzimmersM Offline
                                      mzimmers
                                      wrote on last edited by
                                      #22

                                      @kshegunov alas, that didn't work, either. You're right, though...this is one awkward interface.

                                      kshegunovK 1 Reply Last reply
                                      0
                                      • mzimmersM mzimmers

                                        @kshegunov alas, that didn't work, either. You're right, though...this is one awkward interface.

                                        kshegunovK Offline
                                        kshegunovK Offline
                                        kshegunov
                                        Moderators
                                        wrote on last edited by kshegunov
                                        #23

                                        You mean it didn't fix the double folder thing or you still can't load the image?

                                        Your resource file should look something like this:
                                        0_1508885208545_Screenshot_20171025_014608.png

                                        Then you'd load with :/images/20171022_152431.jpg.

                                        Read and abide by the Qt Code of Conduct

                                        1 Reply Last reply
                                        0
                                        • mzimmersM Offline
                                          mzimmersM Offline
                                          mzimmers
                                          wrote on last edited by
                                          #24

                                          Yes my resource file looks similar to yours. The image displays when dynamically built, but not static.

                                          kshegunovK 1 Reply Last reply
                                          0

                                          • Login

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