[Qt-interest] QTree* with custom widgets

André Somers andre at familiesomers.nl
Tue Mar 17 23:30:47 CET 2009


Hi,

"Bernhard Friedreich" <friesoft at gmail.com> schreef in bericht 
news:49BFB69F.80608 at googlemail.com...
> Andre Somers schrieb:

>> What I do if I want to use custom widgets in a view is that I use a
>> small piece of KDE technology that was introduced as Goya.

> Did that.. altough it didn't work out as expected. I've "ported the
> class to pure Qt", subclassed it and tried to use it.. although the tree
> looks totally f****** up because the widgets sit anywhere/nowhere, text
> appears and disapperas as it likes to.. not comparable to a standard
> table with setIndexWidget/setItemWidget from look and feel (you can also
> feel that when using Goya in the Kwin Settings Dialog.. the buttons
> somehow don't feel like real ones).
Hmmm... This feels like you did not subclass properly and implemented the 
memberfunctions correctly. Could you post some code that goes wrong, or even 
better, a minimal example? I am using it myself without problems, but I must 
admit that my widgets are simpler than yours.

> Also my requirements are much higher than anything Goya could satisfy ..
> as far as I remember the limitations, back then when Goya was initially
> designed.
Of course there are limitations, but I am not sure that's what you are 
hitting... Then again: I did not design Goya, I just happen to use it at 
some places, especially if I need clickable links in my list items. Just 
inserting a QLabel with some HTML through Goya works perfectly for that.

> In the attachement you can find a picture of how the QWidget in the tree
> should look like (picture was made with a QTreeView and setIndexWidget
> after expanding the tree again (after adding the second row) it was
> perfectly fine.
>
> Would still appreciate any other comments about how to solve this issues 
> :-)
It does seem like you only need this fancy widget if you are actually 
editing your booking, right? Would it be an option to create a custom 
delegate that can draw the data in a non-editable way, and only replace it 
with an editable, widget-based version if you actually want to modify the 
contents? In that case, you could use the standard Qt methods I would think. 
That would perhaps simplify your problems.

André

 




More information about the Qt-interest-old mailing list