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:
myTableWidget->viewport()->setStyleSheet("background-image: url(:/images/myimage.png); background-repeat:no-repeat;background-attachment:fixed;background-position:bottom right;");
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.
QPalette pal
= myTableWidget
->viewport
()->palette
();
pal.
setBrush( myTableWidget
->viewport
()->backgroundRole
(),
QBrush( QPixmap(":/images/myimage.png")) );
myTableWidget->viewport()->setPalette( pal );
QPalette pal = myTableWidget->viewport()->palette();
pal.setBrush( myTableWidget->viewport()->backgroundRole(), QBrush( QPixmap(":/images/myimage.png")) );
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.
Bookmarks