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 not loading image after changing computers
QtWS25 Last Chance

QLabel not loading image after changing computers

Scheduled Pinned Locked Moved Unsolved General and Desktop
qlabelqwidgetqicon
6 Posts 4 Posters 1.7k 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.
  • S Offline
    S Offline
    SolaVitae
    wrote on 6 Mar 2018, 02:27 last edited by SolaVitae 3 Jun 2018, 02:29
    #1

    I have a news list widget, containing a text box label and a label purely for holding an image, and I recently formated my PC and reinstalled all of my programs ( QT 5.9.2, and MSVC 2017 is what I'm using), and now after moving to my new installation, I'm randomly getting blank images in my application.

    The code being used for the image is

    QIcon newsIcon = QIcon();
    newsIcon.addFile(thumbnailName.c_str(), QSize(200, 113));
    newsItem->l_img->setPixmap(newsIcon.pixmap(newsIcon.actualSize(QSize(200, 113))));
    

    there is a breakpoint set on the .addFile method which shows me the thumbnail name is
    D:\\---\\---\\---\\data\\cache\\news\\Mysteria Teaser Image.png

    A File size check that i inserted is showing the correct file size, as well as i am able to open the file normally and it is actually an image.

    I've tried deleting the image and letting the program redownload them, manually downloading them, or just replacing it with a black box made in paint, and nothing i do seems to show an image, but other parts of my program using the exact same method of displaying an icon/image are working perfectly still.

    These are what my QLabel image boxes are looking like
    alt text

    J 1 Reply Last reply 6 Mar 2018, 06:13
    0
    • H Online
      H Online
      hskoglund
      wrote on 6 Mar 2018, 03:04 last edited by
      #2

      Hi just guessing but you could try to update your graphics driver.

      1 Reply Last reply
      0
      • S Offline
        S Offline
        SolaVitae
        wrote on 6 Mar 2018, 03:07 last edited by
        #3

        they are current

        1 Reply Last reply
        0
        • S SolaVitae
          6 Mar 2018, 02:27

          I have a news list widget, containing a text box label and a label purely for holding an image, and I recently formated my PC and reinstalled all of my programs ( QT 5.9.2, and MSVC 2017 is what I'm using), and now after moving to my new installation, I'm randomly getting blank images in my application.

          The code being used for the image is

          QIcon newsIcon = QIcon();
          newsIcon.addFile(thumbnailName.c_str(), QSize(200, 113));
          newsItem->l_img->setPixmap(newsIcon.pixmap(newsIcon.actualSize(QSize(200, 113))));
          

          there is a breakpoint set on the .addFile method which shows me the thumbnail name is
          D:\\---\\---\\---\\data\\cache\\news\\Mysteria Teaser Image.png

          A File size check that i inserted is showing the correct file size, as well as i am able to open the file normally and it is actually an image.

          I've tried deleting the image and letting the program redownload them, manually downloading them, or just replacing it with a black box made in paint, and nothing i do seems to show an image, but other parts of my program using the exact same method of displaying an icon/image are working perfectly still.

          These are what my QLabel image boxes are looking like
          alt text

          J Offline
          J Offline
          jsulm
          Lifetime Qt Champion
          wrote on 6 Mar 2018, 06:13 last edited by
          #4

          @SolaVitae said in QLabel not loading image after changing computers:

          newsIcon.addFile(thumbnailName.c_str(), QSize(200, 113));

          Why do you use c_str() here?!

          https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          0
          • S Offline
            S Offline
            SolaVitae
            wrote on 6 Mar 2018, 14:56 last edited by
            #5

            its a regular string

            1 Reply Last reply
            0
            • S Offline
              S Offline
              SGaist
              Lifetime Qt Champion
              wrote on 6 Mar 2018, 21:07 last edited by
              #6

              Hi,

              What do you mean by regular string ?

              If it comes from the Windows API, you should then consider using QDir:: fromNativeSeparators.

              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

              6/6

              6 Mar 2018, 21:07

              • Login

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