PDA

View Full Version : Style3sheet problem, QTreeView for specific object



hubbobubbo
11th February 2010, 17:00
Hi

I have a QTreeView called contactList. I want to use a stylesheet specifically for this object.

If I do like this:
QTreeView {
background-image: url(:images/myImg.png);
background-repeat: 0;background-position: center;
background-color: red;
}

It works, but then all QTreeViews will have this style sheet. So I want to do like this:

QTreeView#contactList {
background-image: url(:/images/myImg.png);
background-repeat: 0;background-position: center;
background-color: red;
}

But then nothing happens with that QTreeView.

I am using Windows Vista.

Anyone knows what might be the issue.

I have also tried with a QLineEdit. Same thing, this is ok:
QLineEdit {
background-color: red;
}

but with this nothing happens:
QLineEdit#name {
background-color: red;
}

hubbobubbo
11th February 2010, 18:13
answering myself.

Used setObjectName and it worked.

pitonyak
11th February 2010, 22:15
I assume that you set the object name to contactList .