Styled custom widgets

Rafael Fernández López ereslibre at
Tue Sep 2 22:06:34 BST 2008


> Another approach would be to add a SH_SupportsXXX for every PE_XXX or
> CE_XXX. Providing a QList<int> feels very powerful but I really doubt
> its usefulness beyond this use case (also one has to concat this list
> with the parent style's list and all that). Instead,
> if (style()->styleHint(SH_SupportsXXX)) {
>     style()->drawControlElement(CE_XXX);
> } else {
>     // fall back painting
> }

I really think this is a good solution...

A completely offtopic on this thread idea that I would have loved from 
Trolltech would have been that all widgets have a method (probably pure 
virtual on QWidget):

virtual void drawWidget(QPainter *painter, const QRect &rect) const = 0;

that directly draws the widget with the current attributes to that painter. It 
would be extremely useful now that we want to more or less paint widgets on 
itemviews (we have the "Goya" workaround for that now on KDE...).

The paintEvent method of all widgets would be extremely easy this way:

void paintEvent(QPaintEvent *event)
    QPainter p(this);
    drawWidget(p, event->rect());

But anyway, as I said, hard offtopic =)

Rafael Fernández López.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part.
URL: <>

More information about the kde-core-devel mailing list