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

duplicated background image

Scheduled Pinned Locked Moved Solved General and Desktop
3 Posts 2 Posters 659 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.
  • M Offline
    M Offline
    mayyy
    wrote on last edited by mayyy
    #1

    hello u all ,
    i was trying to set a background image using this code :

    QWidget *myWidget = new QWidget();
    QPixmap bkgnd(":/Images/background.jpg");
    bkgnd = bkgnd.scaled(myWidget->size(), Qt::IgnoreAspectRatio);
    QPalette palette;
    palette.setBrush(QPalette::Background, bkgnd);
    myWidget->setPalette(palette);
    myWidget->setGeometry(0,0,1370,700);

    but i get many duplicated background images , any help plz ?

    1 Reply Last reply
    0
    • Christian EhrlicherC Offline
      Christian EhrlicherC Offline
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @mayyy said in duplicated background image:

      bkgnd = bkgnd.scaled(myWidget->size(), Qt::IgnoreAspectRatio);
      ...
      myWidget->setGeometry(0,0,1370,700);

      wrong order I would guess

      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
      Visit the Qt Academy at https://academy.qt.io/catalog

      M 1 Reply Last reply
      0
      • Christian EhrlicherC Christian Ehrlicher

        @mayyy said in duplicated background image:

        bkgnd = bkgnd.scaled(myWidget->size(), Qt::IgnoreAspectRatio);
        ...
        myWidget->setGeometry(0,0,1370,700);

        wrong order I would guess

        M Offline
        M Offline
        mayyy
        wrote on last edited by mayyy
        #3
        This post is deleted!
        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