Qt 4.3.1 Style Sheet documentation

Published Monday August 13th, 2007
13 Comments on Qt 4.3.1 Style Sheet documentation
Posted in KDE, Qt

After the mega feature enhancements that we added to Style Sheet in 4.3, we have been getting an awful lot of support requests and mails asking for examples to do all sorts of stuff. As a direct consequence, I have added tons of new documentation. What’s cool is that there is a separate example for styling each and every widget in the Customizing Specific Widgets section. Previously, the documentation was one flat html file. But it grew so big that our doc team has now split it up into separate pages. Trivia question: Which is the biggest documentation manual in Qt ? :).

My favorite bit is the Customizing TreeView example. One can style the tree view branches with 5 images. If you don’t like the tree view lines, you need only two. Here’s how it looks:
Tree View Branches

Comments/Suggestions? Leave a note behind.

Do you like this? Share it
Share on LinkedInGoogle+Share on FacebookTweet about this on Twitter

Posted in KDE, Qt

13 comments

Lord Hippo says:

Top five manuals in Qt (by size):

1. Porting to Qt 4
2. qmake Manual
3. Qt Style Sheets
4. Model/View Programming
5. Qt Designer Manual

What do I win? πŸ˜‰

Leo S says:

Awesome! I always wanted to start experimenting with the widget style sheets, but always ran into the problem that I had no idea what could actually be done, and I didn’t feel like guessing at property names. Thank you!

Richard Moore says:

Some notes on how to make images available for stuff like background images.

rich: You can find an example in kdelibs/phonon/kcm/outputdevicechoice.cpp:

const QColor bgColor = deviceList->viewport()->palette().color(deviceList->viewport()->backgroundRole());
const QString stylesheet = QString(“QListView {”
“background-color: %1;”
“background-image: url(%2);”
“background-position: bottom left;”
“background-attachment: fixed;”
“background-repeat: no-repeat;”
“}”)
.arg(bgColor.name())
.arg(KStandardDirs::locate(“data”, “kcm_phonon/listview-background.png”));
deviceList->setStyleSheet(stylesheet);

mfx- says:

Hi! I only have one question. Is it somehow possible to get this new documentation integrated into my local Qt Assistant installation? I’m developing my diplom work in Qt/C++ and would like to have fancy looking widgets and stuff to impress my supervisor (beyond the code and ideas used) with these… πŸ™‚

afk says:

it possible to add “rich text” for TreeView’s item (or any ModelItem) ? how i can customize items (exept background/foreground)?

girish says:

Rich, yes, that question has been asked quite a few times (as to the options available in making background images available). We will consider adding a section.
afk, AFAIK, currently you have to create your own delegate for setting rich text.

Zandru says:

Very nice! (But also very overdue! πŸ˜‰

More images would be an improvement. How about a new example program that is more suitable for testing than examples/widgets/stylesheet ?

girish says:

Zandru, Agreed. The example is very very very out of date πŸ™‚

girish says:

mfx, sure. The latest qt-all-opensouce packages contain the Qt documentation sources and a utility called qdoc (under $QTDIR/tools/qdoc3). Compile qdoc and run “qdoc3 test/qt.qdocconf” to create the html.

Stephan says:

Great! Just what I needed…One question though ‘alternate colors’ related: is there a way of having alternate color first as the background color of an item, then of having white in a QTreeWidget

girish says:

Stephan, alternate-background-color paints alternate rows. The rest is the background, so

So, QListView {
background-color: first_row_color;
alternate-background-color: second_row_color;
}

Stephan says:

Thanks girish! The style sheet effect looks strange on Qt 4.3.0. The background and alternate colors are quite alike, dark;…guess I’ll upgrade to Qt 4.3.1. πŸ™‚ Can I set the alignment of icons, checkboxes(no QItemDelegate subclassing) of QTreeWidgetItems in a QTreeWidget?

Commenting closed.

Get started today with Qt Download now