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

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.
  • SolaVitaeS Offline
    SolaVitaeS Offline
    SolaVitae
    wrote on last edited by SolaVitae
    #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

    jsulmJ 1 Reply Last reply
    0
    • hskoglundH Offline
      hskoglundH Offline
      hskoglund
      wrote on last edited by
      #2

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

      1 Reply Last reply
      0
      • SolaVitaeS Offline
        SolaVitaeS Offline
        SolaVitae
        wrote on last edited by
        #3

        they are current

        1 Reply Last reply
        0
        • SolaVitaeS SolaVitae

          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

          jsulmJ Offline
          jsulmJ Offline
          jsulm
          Lifetime Qt Champion
          wrote on 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
          • SolaVitaeS Offline
            SolaVitaeS Offline
            SolaVitae
            wrote on last edited by
            #5

            its a regular string

            1 Reply Last reply
            0
            • SGaistS Offline
              SGaistS Offline
              SGaist
              Lifetime Qt Champion
              wrote on 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

              • Login

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