PDA

View Full Version : background image in QTreeView



momesana
6th January 2007, 12:51
Hi,
I am trying to set the background image of a QTreeView to a png image via Stylesheet instructions and this works somehow, but it makes the background color of the View turn transparent. If I then set the background-color to anything other than "background-color:transparent;" the background-image disappears. Comment out the background-color instruction in the code below to get the picture ...
Is this a bug in Qt or am I doing something wrong?

Thanx in advance
Momesana

p.s. I am using Qt-4.2.2


#include <QApplication>
#include <QtGui>

int main(int argc, char ** argv)
{
QApplication app(argc, argv);
QTreeView * view = new QTreeView;
view->resize(500, 350);
view->setStyleSheet
(
"QTreeView {"
// "background-color:white;"
"background-image:url(:images/toque.png);"
"background-position:bottom right;"
"background-repeat:none;"
"}"
);
view->show();
return app.exec();
}

jpn
6th January 2007, 13:06
Qt Style Sheets - List of Attributes (http://doc.trolltech.com/4.2/stylesheet.html#list-of-attributes)


QAbstractItemView, QLineEdit, QMenu, QMenuBar, and QTextEdit don't support background images.

momesana
11th January 2007, 07:25
Qt Style Sheets - List of Attributes (http://doc.trolltech.com/4.2/stylesheet.html#list-of-attributes)
Hehe, I just realized what I was so confused about the fact that this attribute is not supported in Qt-4.2.2 even though I was sure I had seen it in some example ...
http://www.informatik.uni-bremen.de/~momesana/background-image.jpg

That screenshot was taken from the Qt-4.2.0 documentation that I have on my local filesystem and use as a reference. In there, QTreeView ist explicitly given as an example for the background-image StyleSheet instruction. :-)

Cheers
Momesana