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. Image & release problem
Qt 6.11 is out! See what's new in the release blog

Image & release problem

Scheduled Pinned Locked Moved Unsolved General and Desktop
7 Posts 4 Posters 567 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.
  • T Offline
    T Offline
    tjl34567
    wrote on last edited by
    #1

    Hi,

    I've been using QT for several years, but have just changed to the latest. I was using something like QT 5.6. Now its QT creator 14.0.0 based on QT 6.7.2

    However I'm having a couple of problems that I hope someone can help me with.

    In the older version I displayed some images in QPushButtons, but now they only seem to work on a debug build and not on a release one.

    this is a copy of the code I have from a simple app.

        string im = "C:/some path/some filename.jpg";
        QImage qim(im.c_str());
        bool bim = qim.isNull();
    
        QPixmap pix (im.c_str());
    
        QIcon buttonIcon(pix);
        QSize iconSize;
        int w = 60;
        int h = 30;
        iconSize.setWidth(w);
        iconSize.setHeight(h);
    
        bool bp = pix.isNull();
        bool bi = buttonIcon.isNull();
    
        ui->pushButton_2->setIcon(buttonIcon);
        ui->pushButton_2->setIconSize(iconSize);
    

    but as farf as I can tell in the release runs all the images are null. i.e. bim, bp and bi are all true.

    in a debug run they all seem to work fine. I've tried with a gif file as well as a jpg and that has the same problem.

    It could be something to do with how it's started I guess. i.e. I build it in qt creator and get the results above when I run from inside qtcreator, and if I just try running the exe directly I get the images are null failures in both the debug and release build.

    A similar issue I now have is that if I try to run my apps they seem to need a bunch of dlls in the same directory which they never needed before. (like QT6Gui.dll)

    JonBJ J.HilkJ 2 Replies Last reply
    0
    • T tjl34567

      Hi,

      I've been using QT for several years, but have just changed to the latest. I was using something like QT 5.6. Now its QT creator 14.0.0 based on QT 6.7.2

      However I'm having a couple of problems that I hope someone can help me with.

      In the older version I displayed some images in QPushButtons, but now they only seem to work on a debug build and not on a release one.

      this is a copy of the code I have from a simple app.

          string im = "C:/some path/some filename.jpg";
          QImage qim(im.c_str());
          bool bim = qim.isNull();
      
          QPixmap pix (im.c_str());
      
          QIcon buttonIcon(pix);
          QSize iconSize;
          int w = 60;
          int h = 30;
          iconSize.setWidth(w);
          iconSize.setHeight(h);
      
          bool bp = pix.isNull();
          bool bi = buttonIcon.isNull();
      
          ui->pushButton_2->setIcon(buttonIcon);
          ui->pushButton_2->setIconSize(iconSize);
      

      but as farf as I can tell in the release runs all the images are null. i.e. bim, bp and bi are all true.

      in a debug run they all seem to work fine. I've tried with a gif file as well as a jpg and that has the same problem.

      It could be something to do with how it's started I guess. i.e. I build it in qt creator and get the results above when I run from inside qtcreator, and if I just try running the exe directly I get the images are null failures in both the debug and release build.

      A similar issue I now have is that if I try to run my apps they seem to need a bunch of dlls in the same directory which they never needed before. (like QT6Gui.dll)

      JonBJ Offline
      JonBJ Offline
      JonB
      wrote on last edited by
      #2

      @tjl34567 said in Image & release problem:

      It could be something to do with how it's started I guess. i.e. I build it in qt creator and get the results above when I run from inside qtcreator, and if I just try running the exe directly I get the images are null failures in both the debug and release build.

      Your code string im = "C:/some path/some filename.jpg"; implies you are using an absolute path. Is that really the case? Behaviour would not be unexpected if you use a relative path here, as that relies on the current working directory which may not be the same inside vs outside Creator.

      Might be related for DLLs. They must be found either in the current directory or same as executable (can't recall which, might be the latter) or on the PATH .

      1 Reply Last reply
      0
      • T Offline
        T Offline
        tjl34567
        wrote on last edited by
        #3

        yes I put in the complete path just to try to make sure it was working correctly. Really I will start from the exe location and navigate to the images folder, but I just need it make something work first

        I think I've set up PATH - I added ;C:\Qt\Tools\QtCreator\bin to it which is where I found the dll's it said I was missing, but that doesn't seem to help. It all feels odd. I'm almost sure on the old version I had something similar, but certainly not under qtcreator. maybe c:\qt\5.6\bin

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

          Hi,

          On which version of Windows are you working ?
          By the way, why not use QString for your paths rather than doing these conversions ?

          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
          • T Offline
            T Offline
            tjl34567
            wrote on last edited by
            #5

            windows 10 home on this laptop - and literally a new one has just arrived using windows 11.
            I just prefer string to QString - no real reason, just using the same one all the time just means I know where I am (forever adding .c_str() to convert for QT functions :-)
            If its even vaguely possibly causing a problem I could try changing it

            1 Reply Last reply
            0
            • T tjl34567

              Hi,

              I've been using QT for several years, but have just changed to the latest. I was using something like QT 5.6. Now its QT creator 14.0.0 based on QT 6.7.2

              However I'm having a couple of problems that I hope someone can help me with.

              In the older version I displayed some images in QPushButtons, but now they only seem to work on a debug build and not on a release one.

              this is a copy of the code I have from a simple app.

                  string im = "C:/some path/some filename.jpg";
                  QImage qim(im.c_str());
                  bool bim = qim.isNull();
              
                  QPixmap pix (im.c_str());
              
                  QIcon buttonIcon(pix);
                  QSize iconSize;
                  int w = 60;
                  int h = 30;
                  iconSize.setWidth(w);
                  iconSize.setHeight(h);
              
                  bool bp = pix.isNull();
                  bool bi = buttonIcon.isNull();
              
                  ui->pushButton_2->setIcon(buttonIcon);
                  ui->pushButton_2->setIconSize(iconSize);
              

              but as farf as I can tell in the release runs all the images are null. i.e. bim, bp and bi are all true.

              in a debug run they all seem to work fine. I've tried with a gif file as well as a jpg and that has the same problem.

              It could be something to do with how it's started I guess. i.e. I build it in qt creator and get the results above when I run from inside qtcreator, and if I just try running the exe directly I get the images are null failures in both the debug and release build.

              A similar issue I now have is that if I try to run my apps they seem to need a bunch of dlls in the same directory which they never needed before. (like QT6Gui.dll)

              J.HilkJ Offline
              J.HilkJ Offline
              J.Hilk
              Moderators
              wrote on last edited by
              #6

              @tjl34567 seems like you did the release/deployment mechanism by hand, depending on the error popup you get when launching the exe instead of using the provided proper tools.

              you're almost certainly missing the "imageformats" folder and the required dlls, such as: qjpeg.dll qpng.dll besides other stuff

              you should use the windows deployment tool:
              https://doc.qt.io/qt-6/windows-deployment.html


              Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


              Q: What's that?
              A: It's blue light.
              Q: What does it do?
              A: It turns blue.

              1 Reply Last reply
              1
              • T Offline
                T Offline
                tjl34567
                wrote on last edited by
                #7

                OK thanks for all the thoughts. On my new laptop it all seems to work perfectly :-)

                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