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. QLabel with the QPixmap blues

QLabel with the QPixmap blues

Scheduled Pinned Locked Moved Solved General and Desktop
20 Posts 3 Posters 3.3k 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.
  • mranger90M Offline
    mranger90M Offline
    mranger90
    wrote on last edited by mranger90
    #6

    Ok. If dbOn.isNull() is false, then I'd check the width and height of it to see if it matches what is expected. If that all looks ok, then I'd extract the pixmap from the label after assigning it:
    const QPixmap *p = dbOn.pixmap();
    and then check "p" to see if has the expected dimensions.
    If worse comes to worse, make sure that the label is visible.
    Good luck.

    1 Reply Last reply
    0
    • WillyBoy 0W Offline
      WillyBoy 0W Offline
      WillyBoy 0
      wrote on last edited by
      #7

      0_1524747493564_Screenshot from 2018-04-26 08-45-14.jpg

      Ok, they are both invalid. But I can still load them and display them during development so they are valid png and the resource link is valid so I'm not sure where to look next. To be invalid you would think it would be incorrectly formatted but it looks good to me. Any help decrypting this would be appreciated.

      If I have seen further than others... It is because I have stood on the shoulders of giants!

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

        That is a bit odd. Since ressources files are compiled into the exe,
        its hard for them to be invalid.
        if both path is correct and the images can be clicked and shown from within Creator
        they must be valid. Also compiles fails if files are missing.

        Could you try to delete the build folder complete and run qmake and then rebuild all.

        1 Reply Last reply
        0
        • mranger90M Offline
          mranger90M Offline
          mranger90
          wrote on last edited by mranger90
          #9

          Ok, this got my curious so I did some experimenting.
          On Windows (mine is 8.1) there does seem to be some problems with jpg files.
          I pulled a bunch of jpg's from various resources and found that whether they load is hit or miss.
          I'm guessing there is something in the imageformats plug in for windows that rejects some
          files. I don't know enough about the file formats to say why.
          One consistency I found is that if the windows image viewer will display the file, then the Qt app will load it. I have some jpgs that load in other applications, but not the Image Viewer or the Qt app.
          Try converting your image to a PNG and see if you get better results.
          <edit>
          After doing a little more research and dumping the binaries I've found that many images that are labeled as "jpg" are not really JPEGS. Some image readers have no problem with this but the Qt plugin probably does. One situation I found curious is that in QtCreator, I could highlight the resource path of the image and it would display, but not load....

          1 Reply Last reply
          0
          • WillyBoy 0W Offline
            WillyBoy 0W Offline
            WillyBoy 0
            wrote on last edited by
            #10

            Thanks for the responses. First, I did a Clean-All and the qmake, no difference. mranger90, I am developing and trageting Linux Ubuntu so window quarks, not really a problem. Also I use .png as my goto default format for images. Someone asked about the QPixmap being hidden so I change cpp to this...
            0_1524838427450_XX_cpp.png
            Then there's this...
            0_1524838489614_XX_Design.png
            So at run time I get this...0_1524838562776_XX_Run.png

            I would think of a corrupted .qrc file but it compiles with no errors. I'm thinking that there must be something with the way I'm calling for the Pixmap change that is at fault but everywhere I look they reference this method. Can anyone offer a different way? This project is in limbo until I find a way to get this to work. My original app. had numerous events where ToolBar Button icons would change to indicate the state of the classes they controlled. This just seemed to be an easier way.

            If I have seen further than others... It is because I have stood on the shoulders of giants!

            1 Reply Last reply
            0
            • mranger90M Offline
              mranger90M Offline
              mranger90
              wrote on last edited by
              #11

              At this point, all I can suggest is that you simplify.
              Write a really small app, say a dialog with just a QLabel,
              and and try to load your image into the QPixmap both as from an external file,
              and from the resource tree.

              1 Reply Last reply
              1
              • WillyBoy 0W Offline
                WillyBoy 0W Offline
                WillyBoy 0
                wrote on last edited by
                #12

                OK I did as you (and I) wanted and that was do a simple dialog and see what happens. So I built a simple Dialog project ON A DIFFERENT COMPUTER with different resources in the .qrc file and the results were exactly the same.

                0_1524963121314_BuildProb_001.png

                So I can only suspect that my method is in error. Can someone lend who or how I can resolve. Can someone do the same with a quick project and either confirm my results or, and I hope, show me my error(s). Thanks for all the support.

                If I have seen further than others... It is because I have stood on the shoulders of giants!

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

                  Hi
                  I cant guess what goes wrong. all seems fine. :)

                  Sample here.
                  https://www.dropbox.com/s/q41hgzc36xqx482/mycons.zip?dl=0

                  expected result.
                  alt text

                  1 Reply Last reply
                  1
                  • WillyBoy 0W Offline
                    WillyBoy 0W Offline
                    WillyBoy 0
                    wrote on last edited by
                    #14

                    PROBLEM SOLVED
                    I want to thank mrjj for making a simple project "mycons". It was when I looked at his files and made a quick comparison that the solution jumped out at me. When he made his .qrc file he added icons that were in the root folder. I was porting over a Borland project and just used the same folders for graphics I used back then. They were in sub folders according to pixel size, '16' '24' and '32'. I just batched renamed the 32_XXX with size first then _sequential numbers. When I wanted to get the name I just looked in the .qrc and saw <file>32/32_072.png</file> so that is what I used. BUT the <file> line was wrapped in <qresource prefix = "/32"> </qresource>. So when I used :32/32_072.png as the QPixmap file, I should have been using :/32/32/32_072.png. At that time I became blind to the oversight and just went, off the deep end. This is why it is so hard to be a lone programmer, lesson learned. Thanks again mrjj its always the minutia that brings us to our knees. Thanks again to all that responded.

                    If I have seen further than others... It is because I have stood on the shoulders of giants!

                    mrjjM 1 Reply Last reply
                    1
                    • WillyBoy 0W WillyBoy 0

                      PROBLEM SOLVED
                      I want to thank mrjj for making a simple project "mycons". It was when I looked at his files and made a quick comparison that the solution jumped out at me. When he made his .qrc file he added icons that were in the root folder. I was porting over a Borland project and just used the same folders for graphics I used back then. They were in sub folders according to pixel size, '16' '24' and '32'. I just batched renamed the 32_XXX with size first then _sequential numbers. When I wanted to get the name I just looked in the .qrc and saw <file>32/32_072.png</file> so that is what I used. BUT the <file> line was wrapped in <qresource prefix = "/32"> </qresource>. So when I used :32/32_072.png as the QPixmap file, I should have been using :/32/32/32_072.png. At that time I became blind to the oversight and just went, off the deep end. This is why it is so hard to be a lone programmer, lesson learned. Thanks again mrjj its always the minutia that brings us to our knees. Thanks again to all that responded.

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

                      @WillyBoy-0
                      Hi, no troubles.
                      Ah, that was somewhat sneaky.
                      For the record, right clicking the image in project tree, shows the correct path or
                      did it miss the extra 32 path part ?

                      1 Reply Last reply
                      0
                      • WillyBoy 0W Offline
                        WillyBoy 0W Offline
                        WillyBoy 0
                        wrote on last edited by
                        #16

                        Hi mrjj, hovering over an item in the .qrc file displays the raw computer location (again a mislead for me) but right click options are Creator's path (:/32/32/32_073.png) or the url (qrc:/32/32/32_073.png) just remove the qrc bit and that's what is needed.
                        Very cool. One more sidebar, how do I mark this thread SOLVED? Again thanks, btw I'm moving to Florida in the coming weeks so I will have to suspend my project for awhile. But I plan to give renewed life to all 11 of my old Borland projects but most of them need some upgrades to compete today.

                        If I have seen further than others... It is because I have stood on the shoulders of giants!

                        mrjjM 1 Reply Last reply
                        0
                        • WillyBoy 0W WillyBoy 0

                          Hi mrjj, hovering over an item in the .qrc file displays the raw computer location (again a mislead for me) but right click options are Creator's path (:/32/32/32_073.png) or the url (qrc:/32/32/32_073.png) just remove the qrc bit and that's what is needed.
                          Very cool. One more sidebar, how do I mark this thread SOLVED? Again thanks, btw I'm moving to Florida in the coming weeks so I will have to suspend my project for awhile. But I plan to give renewed life to all 11 of my old Borland projects but most of them need some upgrades to compete today.

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

                          @WillyBoy-0
                          Hi
                          On first post u made. In Topic tools. is way to say Solved.
                          Oh, happy moving then.
                          You will find that Qt does most of what VCL does/did.
                          I hope its that new and not the good old OWL ;)

                          1 Reply Last reply
                          0
                          • WillyBoy 0W Offline
                            WillyBoy 0W Offline
                            WillyBoy 0
                            wrote on last edited by
                            #18

                            Yup, VCL! Most for what I did was local db (back then, Paradox 7, with the BDE) with focus on the Automotive Repair industry. With an offshoot to Independent Day Care Software for small to medium in-home sites. A sysbar app GotMail? for email notification (2003), outdated now. But I have stuff to keep me busy for awhile. I won't miss Pennsylvania winters, that's for sure!

                            If I have seen further than others... It is because I have stood on the shoulders of giants!

                            mrjjM 1 Reply Last reply
                            0
                            • WillyBoy 0W WillyBoy 0

                              Yup, VCL! Most for what I did was local db (back then, Paradox 7, with the BDE) with focus on the Automotive Repair industry. With an offshoot to Independent Day Care Software for small to medium in-home sites. A sysbar app GotMail? for email notification (2003), outdated now. But I have stuff to keep me busy for awhile. I won't miss Pennsylvania winters, that's for sure!

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

                              @WillyBoy-0
                              Hehe i guess nobody would miss Pennsylvania winters :)

                              To replace BDE, Sqlite might be handy. Qt has excellent support.
                              (if needs are only local db)

                              1 Reply Last reply
                              0
                              • WillyBoy 0W Offline
                                WillyBoy 0W Offline
                                WillyBoy 0
                                wrote on last edited by
                                #20

                                In an earlier post you can see I've already committed to SQLite,. It seamed to be a logical choice and mirrors Paradox pretty close, as far as function. I've done MySQL both local and remote before and it's pretty straight forward and easy to use but I see it as a Mustang when a Escort will do. And besides, copy and paste is a DB backup dream.

                                If I have seen further than others... It is because I have stood on the shoulders of giants!

                                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