[Qt-interest] QTree* with custom widgets

Bernhard Friedreich friesoft at gmail.com
Wed Mar 18 20:06:42 CET 2009


Malyushytsky, Alex schrieb:
> The problem might not be related to how you are trying to update QTreeWidget.
> I don't see how removing widget and inserting it again might not work.
>   
The widgets get's deleted as soon as you do another setIndexWidget (can 
also be read in the docs -- setIndexWidget)
> In this case you will have to assume it did not work initially.
>
> It might be related to when you are trying to do it.
> It probably has to be done when widget is already updated its geometry.
>
> Try to check it in the following way.
> Add button or menu action, conect clicked signal to slot where you call dataChanged, or any other way you were trying to update QTreeWidget.
> Click this button when normally you collapse/expand item by mouse.
> Effect should be the same - widget should be updated.
>
> Try to use timer (it can be 0) to post event when you think your widget is ready and call dataChanged as a reaction on this event.
>   
Didn't try them (yet?) cause I've (temporarly?) switched over to another 
solution.. I'm just using a normal QScrollArea with buttons on the left 
to show/hide widgets and the widgets on the right.. works perfectly.. is 
really easy.. and as soon as the buttons are styled the right way (tm) 
it will all fit to the application design :-)

THANKS for your help but it's the first time that Qt could have been 
easier :D
> Alex
>
> ________________________________________
> From: qt-interest-bounces at trolltech.com [mailto:qt-interest-bounces at trolltech.com] On Behalf Of Bernhard Friedreich
> Sent: Tuesday, March 17, 2009 8:00 AM
> To: qt-interest at trolltech.com
> Subject: Re: [Qt-interest] QTree* with custom widgets
>
> Malyushytsky, Alex schrieb:
> Now the case with setIndexWidget/setItemWidget is that the size of the QTreeWidgetItem (or whatever you'd like to call it) doesn't change as long as I don't collpase and reopen the tree again.
>
>
> This means that all you need is to force QTreeWidget to update when you done editing (you will have to figure out when yourself, cause it depends on your widget)
>
> actually had the same idea first (see below)
>
>
> I am sure it should be a way.
> You could always do the following, cause it is equivalent of what you were doing with probably even completely acceptable graphics update.
> - setUpdatesEnabled ( false );
>  - collapse/ expand
>    or removeItemWidget and insert it back (should inforce updating this widget.
> - setUpdatesEnabled ( true );
>
> tried it.. didn't work.. even tried to recreate the signals emitted when the user interacts with the tree.. far to impossible because you'd have to get the right cursor positions and such stuff...
> didn't work means: nothing changes (doesn't resize like it does when the user collapses and expands the tree)
>
>
> But I believe there should be direct way to inforce QTreeWidget to update
>
> I don't have access to my development machine right now, so can't test it , but hope can give you some hints.
>
> 1. check that uniformRowHeights () is false.
>
> checked
>
> 2. try call update() on QTreeWidget
>
> didn't do anything. also tried to use updateGeometry.. didn't work, updateGeometries (sounds good imo) also doesn't work, as expandAll and dataChanged don't work :-(
>
>
> 3. Finally check what is called in QAbstractItemView::setIndexWidget(...)
> (QT source) to update geometry. It should be
> QAbstractItemView::dataChanged ( ... ).
> Call it yourself. This probably is the best way and should work.
>
> as stated above: it doesn't work -- furthermore I can't get a valid index (using a QTreeWidget) -- but maybe this was because it was just a quick and dirty hack and I overlooked something
>
>
> Regards,
>    Alex
>
>
> ________________________________________
> From: Bernhard Friedreich [mailto:friesoft at gmail.com]
> Sent: Monday, March 16, 2009 3:17 AM
> To: Malyushytsky, Alex
> Subject: Re: [Qt-interest] QTree* with custom widgets
>
> Because the widgets needs the ability to be resized! (dynamic content)
> >From the Qt docu:
> This function should only be used to display static content in the place of a tree widget item. If you want to display custom dynamic content or implement a custom editor widget, use QTreeView and subclassQItemDelegate instead.
>
> 2009/3/16 Malyushytsky, Alex <alex at wai.com>
> Why QTreeWidget::setItemWidget is not working for you?
>
> void QTreeWidget::setItemWidget ( QTreeWidgetItem * item, int column, QWidget * widget )
>
> Regards,
>    Alex
>
>
>
>
> ________________________________________
> From: qt-interest-bounces at trolltech.com [mailto:qt-interest-bounces at trolltech.com] On Behalf Of Bernhard Friedreich
> Sent: Sunday, March 15, 2009 1:44 PM
> To: qt-interest at trolltech.com
> Subject: [Qt-interest] QTree* with custom widgets
>
> Hey!
>
> I've been fighting with a problem for quite some time now and I've now reached the point from which on I have now idea what is left, I could try. I really hope you guys (and girls ^^) can help me.
>
> I want to use a QTreeView or QTreeWidget (doesn't really matter) with custom widgets.
>
> I've got those requirements:
> * Custom widgets (different rows = different widgets, 0st column: normal description text, 1st column: the widget)
> * dynamic resizing (adding widgets at runtime to the custom widget)
> * the widgets must be shown all the time (NOT JUST FOR EDITING!)
> I've tried setIndexWidget, setItemWidget, a QGraphicsView and ItemDelegates with the paint method..
>
> Already searched on many forums, google and mailings lists but nothing useable turned up.
>
> Here's the thread where I asked for help (provides some more information): http://www.qtforum.org/article/27021/qtree-with-custom-qwidgets.html
>
> I'd REALLY appreciate if you could help me... I'm totally lost atm...
>
> Thanks for your help :-)
>
> Best regards,
> Bernhard Friedreich, Qt fan and developer :-P
>
>
> ---------------------------------------------------------------------------------------------------
> Weidlinger Associates, Inc. made the following annotations.
>
> "This message and any attachments are solely for the intended recipient and may contain confidential or privileged information. If you are not the intended recipient, any disclosure, copying, use, or distribution of the information included in this message and any attachments is prohibited. If you have received this communication in error, please notify us by reply e-mail and immediately and permanently delete this message and any attachments. Thank you."
>
> "Please consider our environment before printing this email."
>
> _______________________________________________
> Qt-interest mailing list
> Qt-interest at trolltech.com
> http://lists.trolltech.com/mailman/listinfo/qt-interest
>
>
> "This message and any attachments are solely for the intended recipient and may contain confidential or privileged information. If you are not the intended recipient, any disclosure, copying, use, or distribution of the information included in this message and any attachments is prohibited. If you have received this communication in error, please notify us by reply e-mail and immediately and permanently delete this message and any attachments. Thank you."
>
>
> ________________________________________
>
> _______________________________________________
> Qt-interest mailing list
> Qt-interest at trolltech.com
> http://lists.trolltech.com/mailman/listinfo/qt-interest
>
>
>
> _______________________________________________
> Qt-interest mailing list
> Qt-interest at trolltech.com
> http://lists.trolltech.com/mailman/listinfo/qt-interest
>
>
>
>
> "This message and any attachments are solely for the intended recipient and may contain confidential or privileged information. If you are not the intended recipient, any disclosure, copying, use, or distribution of the information included in this message and any attachments is prohibited. If you have received this communication in error, please notify us by reply e-mail and immediately and permanently delete this message and any attachments. Thank you."
>
> _______________________________________________
> Qt-interest mailing list
> Qt-interest at trolltech.com
> http://lists.trolltech.com/mailman/listinfo/qt-interest
>
>   




More information about the Qt-interest-old mailing list