Results 1 to 4 of 4

Thread: Setting Dynamic Back ground image on QTableWidget

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2010
    Posts
    13
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Post Setting Dynamic Back ground image on QTableWidget

    Hi There.

    Simple question, but I can't figure out how to make it work.
    I want to set an image to be always at the bottom right hand corner of my QTableWidget. I've got this to work by setting the following:

    Qt Code:
    1. myTableWidget->viewport()->setStyleSheet("background-image: url(:/images/myimage.png); background-repeat:no-repeat;background-attachment:fixed;background-position:bottom right;");
    To copy to clipboard, switch view to plain text mode 

    This work exactly as I wanted. However I've now come to enhance some features and my image now needs to be dynamic. I have a class that return a QPixmap with the appropriate image. I don't want to save the physical file to a harddrive because I may have multiple version of the same control open at the same time all requireing different images, and I don't want to clog up the users hard drive with temporary images.

    I've tried lots of different variation of the following all with little success.

    Qt Code:
    1. QPalette pal = myTableWidget->viewport()->palette();
    2. pal.setBrush( myTableWidget->viewport()->backgroundRole(), QBrush( QPixmap(":/images/myimage.png")) );
    3. myTableWidget->viewport()->setPalette( pal );
    To copy to clipboard, switch view to plain text mode 

    This sort of works, but it's on the top right and when I scroll the table columns from left to right the image breaks up, also the image scrolls and is not fixed to possition.

    Anyhelp would be apprechiated.
    Last edited by dholliday; 16th May 2011 at 12:25.

Similar Threads

  1. Replies: 0
    Last Post: 19th January 2011, 12:49
  2. Changing Qt's green application back ground color
    By anafor2004 in forum Qt Programming
    Replies: 0
    Last Post: 17th June 2009, 11:58
  3. qcombobox back ground coloring
    By sreedhar in forum Qt Programming
    Replies: 1
    Last Post: 20th December 2006, 19:29
  4. qCheckbox back ground color
    By sreedhar in forum Qt Programming
    Replies: 1
    Last Post: 20th December 2006, 18:44
  5. problem with the back ground image
    By Seema Rao in forum Qt Programming
    Replies: 1
    Last Post: 17th April 2006, 21:34

Tags for this Thread

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
  •  
Qt is a trademark of The Qt Company.