Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Not displaying image in the window

    General and Desktop
    5
    5
    1291
    Loading More Posts
    • 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
      shalinir last edited by

      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 Reply Quote 0
      • S
        stukdev last edited by

        BG without extension?

        1 Reply Last reply Reply Quote 0
        • A
          andre last edited by

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

          1 Reply Last reply Reply Quote 0
          • T
            tzander last edited by

            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 Reply Quote 0
            • P
              postal267 last edited by

              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 Reply Quote 0
              • First post
                Last post