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. Problem with ressource file
Qt 6.11 is out! See what's new in the release blog

Problem with ressource file

Scheduled Pinned Locked Moved Unsolved General and Desktop
qt 5.7
16 Posts 5 Posters 4.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.
  • SGaistS Offline
    SGaistS Offline
    SGaist
    Lifetime Qt Champion
    wrote on last edited by
    #4

    Hi and welcome to devnet,

    Can you share the content of the file ?

    And an example of line you use to load an image in a QLabel ?

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

    cpperC 1 Reply Last reply
    1
    • SGaistS SGaist

      Hi and welcome to devnet,

      Can you share the content of the file ?

      And an example of line you use to load an image in a QLabel ?

      cpperC Offline
      cpperC Offline
      cpper
      wrote on last edited by cpper
      #5

      @SGaist
      File untitled3.pro:

      #-------------------------------------------------

      Project created by QtCreator 2016-07-25T14:54:55

      #-------------------------------------------------

      QT += core gui

      greaterThan(QT_MAJOR_VERSION, 4): QT += widgets

      TARGET = untitled3
      TEMPLATE = app

      SOURCES += main.cpp
      mainwindow.cpp

      HEADERS += mainwindow.h

      FORMS += mainwindow.ui

      RESOURCES +=
      ress.qrc


      Here I load the pic in the QLabel. It's also highlighted in the image in the first post:

      ui->pic->setPixmap(pic.scaled(ui->pic->width(),ui->pic->height(),Qt::KeepAspectRatio));

      ui->pic is the QLabel
      pic is the QPixmal created above.

      1 Reply Last reply
      0
      • miclandM Offline
        miclandM Offline
        micland
        wrote on last edited by
        #6

        The code in the screeshot looks fine.
        Did you specify an alias in the qrc-file?
        Can you paste the plaintext content of the qrc-file?

        cpperC 1 Reply Last reply
        1
        • miclandM micland

          The code in the screeshot looks fine.
          Did you specify an alias in the qrc-file?
          Can you paste the plaintext content of the qrc-file?

          cpperC Offline
          cpperC Offline
          cpper
          wrote on last edited by
          #7

          @micland I haven't specified an alias(Actually don't know what that is,anyway)

          Here is the content of the qrc:

          <RCC>
          <qresource prefix="/">
          <file>cio.jpg</file>
          </qresource>
          </RCC>

          1 Reply Last reply
          0
          • VRoninV Offline
            VRoninV Offline
            VRonin
            wrote on last edited by
            #8

            can you show how you construct pic? it should be QPixmap pic(":/cio.jpg");

            "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
            ~Napoleon Bonaparte

            On a crusade to banish setIndexWidget() from the holy land of Qt

            cpperC 1 Reply Last reply
            1
            • VRoninV VRonin

              can you show how you construct pic? it should be QPixmap pic(":/cio.jpg");

              cpperC Offline
              cpperC Offline
              cpper
              wrote on last edited by
              #9

              @VRonin You can see that in the screenshot from the first post. It's the same as your line.

              1 Reply Last reply
              0
              • VRoninV Offline
                VRoninV Offline
                VRonin
                wrote on last edited by VRonin
                #10

                Is rcc run on the resource file at all?

                qmake is terrible at detecting changes in the .pro file, try clearing everything and then rebuild

                "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
                ~Napoleon Bonaparte

                On a crusade to banish setIndexWidget() from the holy land of Qt

                cpperC 1 Reply Last reply
                1
                • VRoninV VRonin

                  Is rcc run on the resource file at all?

                  qmake is terrible at detecting changes in the .pro file, try clearing everything and then rebuild

                  cpperC Offline
                  cpperC Offline
                  cpper
                  wrote on last edited by
                  #11

                  @VRonin I've rebuild the project, still can't see the image. I'll try on a fresh project right now.

                  cpperC 1 Reply Last reply
                  0
                  • VRoninV Offline
                    VRoninV Offline
                    VRonin
                    wrote on last edited by VRonin
                    #12

                    Also, the .pro file that you posted should not work correctly. Newlines in pro files are the same as ; in C++

                    RESOURCES +=
                    ress.qrc
                    

                    should become

                    RESOURCES += ress.qrc
                    

                    same as

                    SOURCES += main.cpp
                    mainwindow.cpp
                    

                    should become

                    SOURCES += main.cpp \
                    mainwindow.cpp
                    

                    "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
                    ~Napoleon Bonaparte

                    On a crusade to banish setIndexWidget() from the holy land of Qt

                    cpperC the_T 2 Replies Last reply
                    1
                    • VRoninV VRonin

                      Also, the .pro file that you posted should not work correctly. Newlines in pro files are the same as ; in C++

                      RESOURCES +=
                      ress.qrc
                      

                      should become

                      RESOURCES += ress.qrc
                      

                      same as

                      SOURCES += main.cpp
                      mainwindow.cpp
                      

                      should become

                      SOURCES += main.cpp \
                      mainwindow.cpp
                      
                      cpperC Offline
                      cpperC Offline
                      cpper
                      wrote on last edited by
                      #13

                      @VRonin Are you sure ? I haven't touched anything in the .pro file. It just auto-generated content, and I guess the compiler knows what he's doing

                      1 Reply Last reply
                      0
                      • cpperC cpper

                        @VRonin I've rebuild the project, still can't see the image. I'll try on a fresh project right now.

                        cpperC Offline
                        cpperC Offline
                        cpper
                        wrote on last edited by
                        #14

                        The same code worked on a fresh project and I can see the image. Strange.

                        1 Reply Last reply
                        0
                        • VRoninV Offline
                          VRoninV Offline
                          VRonin
                          wrote on last edited by
                          #15

                          That means rcc was definitely not running

                          "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
                          ~Napoleon Bonaparte

                          On a crusade to banish setIndexWidget() from the holy land of Qt

                          1 Reply Last reply
                          2
                          • VRoninV VRonin

                            Also, the .pro file that you posted should not work correctly. Newlines in pro files are the same as ; in C++

                            RESOURCES +=
                            ress.qrc
                            

                            should become

                            RESOURCES += ress.qrc
                            

                            same as

                            SOURCES += main.cpp
                            mainwindow.cpp
                            

                            should become

                            SOURCES += main.cpp \
                            mainwindow.cpp
                            
                            the_T Offline
                            the_T Offline
                            the_
                            wrote on last edited by
                            #16

                            @VRonin

                            I tried to quote the post that contained the pro file, and it was correct with \ in the RESOURCE line

                            Sometimes backslashes are "consumed" here :)

                            -- No support in PM --

                            1 Reply Last reply
                            2

                            • Login

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