Results 1 to 4 of 4

Thread: How to set background image with no-repeat (without using CSS)

  1. #1
    Join Date
    Oct 2006
    Posts
    83
    Thanks
    1
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default How to set background image with no-repeat (without using CSS)

    I currently have code that sets a widgets background to a desired image. However, by default it is tiling the image. I'm trying to make it so that it does not repeat. I was able to use CSS stylesheet's to do this, but it ended up lagging my program on load. Therefore, I decided to use a different method. Below is the code I have so far, and if anyone can help me figure out how to make it not repeat the image, I would appreciate it:

    Qt Code:
    1. QPalette p = this->palette();
    2. p.setBrush(QPalette::Window, QPixmap(QString(":imageLocation")));
    3. this->setPalette(p);
    4. this->setAutoFillBackground(true);
    To copy to clipboard, switch view to plain text mode 

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: How to set background image with no-repeat (without using CSS)

    Is it a custom widget? Maybe you can paint it yourself?

  3. #3
    Join Date
    Oct 2006
    Posts
    83
    Thanks
    1
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: How to set background image with no-repeat (without using CSS)

    Although a weak solution, this is what got the job done:

    Through Designer:
    I simply created a QLabel and set the Pixmap of the label to be my background image. I then made sure that this new label was moved to the back, so that it was behind all other form items.

  4. #4

    Default Re: How to set background image with no-repeat (without using CSS)

    QT cannot do too much.
    Cannot move icon/background image/border image to a fixed position.
    And now, it stop you do it outside a customer widget.
    So the only way is to paint by yourself, perfect.

Similar Threads

  1. Background image on popup menu item
    By MarkoSan in forum Qt for Embedded and Mobile
    Replies: 1
    Last Post: 27th June 2006, 05:55
  2. problem with the back ground image
    By Seema Rao in forum Qt Programming
    Replies: 1
    Last Post: 17th April 2006, 21:34
  3. How and when to repaint a widget ?
    By yellowmat in forum Newbie
    Replies: 7
    Last Post: 3rd April 2006, 16:36
  4. How to implement a ListBox with background image
    By andyyeh75 in forum Qt Programming
    Replies: 3
    Last Post: 8th March 2006, 08:55
  5. [QT4.1.1 XP] background image
    By incapacitant in forum Newbie
    Replies: 3
    Last Post: 1st March 2006, 13:02

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.