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. How to stretch the background image?

How to stretch the background image?

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

    Hi.
    How to stretch the background image?
    The image does not stretch.

        QPalette Pal(palette());
        //QImage background(":/Images/Images/splash-background.png");
        QImage background(":/Images/Images/ico-qr.png");
        Pal.setBrush(QPalette::Background, background);
        this->setAutoFillBackground(true);
        this->setPalette(Pal);
    

    or

     this->setStyleSheet("background-image: url(:/Images/Images/ico-qr.png); ");
    
    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      See this thread for inspiration.

      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
      1
      • M Offline
        M Offline
        Mikeeeeee
        wrote on last edited by
        #3
            QPixmap bkgnd(":/Images/Images/splash-background.png");
            bkgnd = bkgnd.scaled(size(), Qt::IgnoreAspectRatio);
            QPalette p = palette(); //copy current, not create new
            p.setBrush(QPalette::Background, bkgnd);
            setPalette(p);
        
        1 Reply Last reply
        1

        • Login

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