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. [Solved] Images in qt application not loading.
Forum Updated to NodeBB v4.3 + New Features

[Solved] Images in qt application not loading.

Scheduled Pinned Locked Moved General and Desktop
24 Posts 6 Posters 29.0k 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.
  • J Offline
    J Offline
    joshua-anderson
    wrote on last edited by
    #15

    I will try the clean advice(never a bad idea). This might be part of the problem with my issues in my reasources file, and this will hopefully fix it. Right now I am trying top figure out why qpixmapand qfile thinks a file with a direct path to disk does not exist when the same path works in qtcreator.

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

      It's normal it's printing false. You're not escaping the \ in your code.

      Anyway since you're using Qt, use the forward slash (yes, like unix) for your paths everywhere and you wont be hit again by this.

      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
      • J Offline
        J Offline
        joshua-anderson
        wrote on last edited by
        #17

        Duh! I feel like a idiot for not noticing that. That should solve the loading image from disk problem. Next, to see if I can load from reasources.

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

          If you have your images in a folder, don't forget to add it in your path

          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
          • J Offline
            J Offline
            joshua-anderson
            wrote on last edited by
            #19

            musimbate, Thank you so much for your advice. It solved my resource loading problem. Why must you be this way windows?!?

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

              That's a question for Microsoft :D

              Anyway, if you have everything working now, don't forget to update the thread title prepending [solved] so other forum users may know a solution has been found :)

              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
              • P Offline
                P Offline
                psteranka
                wrote on last edited by
                #21

                I was running into a problem and it was as simple as running qmake and then re-building, and then viola it worked. I used

                @
                QFile testIt(":/images/mypict.jpg")
                qDebug() << "Are you loading?: " << testIt.exists();
                @

                to verify that the image was NOT loading, but I didn't know why. I searched around for answers but didn't find one that said When you add a resource, you need to re-run qmake.

                I'm posting this in case someone else has the same problem.

                1 Reply Last reply
                0
                • P Offline
                  P Offline
                  psteranka
                  wrote on last edited by
                  #22

                  I was running into a problem and it was as simple as running qmake and then re-building, and then viola it worked. I used

                  @
                  QFile testIt(":/images/mypict.jpg")
                  qDebug() << "Are you loading?: " << testIt.exists();
                  @

                  to verify that the image was NOT loading, but I didn't know why. I searched around for answers but didn't find one that said When you add a resource, you need to re-run qmake.

                  I'm posting this in case someone else has the same problem.

                  1 Reply Last reply
                  0
                  • G Offline
                    G Offline
                    Gmoney
                    wrote on last edited by
                    #23

                    Is there any way to force Designer to use the full path of an icon by default?

                    R 1 Reply Last reply
                    0
                    • G Gmoney

                      Is there any way to force Designer to use the full path of an icon by default?

                      R Offline
                      R Offline
                      reena jaus
                      wrote on last edited by
                      #24

                      @Gmoney just add image to ur .qrc file in qt . and then right click on the image copy full path . then u get the correct path
                      paste that to ur code .it works

                      1 Reply Last reply
                      1

                      • Login

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