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. Not displaying image in the window
Qt 6.11 is out! See what's new in the release blog

Not displaying image in the window

Scheduled Pinned Locked Moved General and Desktop
5 Posts 5 Posters 1.8k Views 1 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.
  • S Offline
    S Offline
    shalinir
    wrote on last edited by
    #1

    the source code
    @QPalette p = palette();
    QPixmap pixmap1(":/new/prefix1/BG");

        QDesktopWidget* desktopWidget = QApplication::desktop();
        QRect rect = desktopWidget->availableGeometry();
    
        QSize size(rect.width() , rect.height());
        QPixmap pixmap(pixmap1.scaled(size));
        p.setBrush(QPalette::Background,  pixmap);
        setPalette(p);@ when the project is built in the output console it displays--QPixmap::scaled: Pixmap is a null pixmap
    
    1 Reply Last reply
    0
    • S Offline
      S Offline
      stukdev
      wrote on last edited by
      #2

      BG without extension?

      1 Reply Last reply
      0
      • A Offline
        A Offline
        andre
        wrote on last edited by
        #3

        So, is the image actually in the resource? Did you deploy the needed image format plugin?

        1 Reply Last reply
        0
        • T Offline
          T Offline
          tzander
          wrote on last edited by
          #4

          yeah, like stuk said; you may have mis-typed the filename :)

          Also would like to suggest you use QImage for opening the image which is much faster than using a pixmap for nothing but scaling.

          1 Reply Last reply
          0
          • P Offline
            P Offline
            postal267
            wrote on last edited by
            #5

            I think you should replace
            QPixmap pixmap1(":/new/prefix1/BG");
            for
            QPixmap pixmap1(":/new/prefix1/BG.png");
            or
            QPixmap pixmap1(":/new/prefix1/BG.jpg");

            you need to put the image extension in the code.

            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