Trolltech Home | Qt-interest Home | Recent Threads | All Threads | Author | Date
All threads index page 1

Qt-interest Archive, February 2007
How keep a group in a tree widget collapsed


Message 1 in thread

Hello dev partners,

First I have a QTreeWidget and I have in it items as groups of other
items.

Now I don't know if setItemExpanded(the item I want to Expand/Collapse is a
group) is a native qt function, so if is, how I can make it collapse, and
how can I put in an "IF" sentence, like "if (item isexpanded)" or
collapse.


 Any help will be great

Dennis Guzmán A

Message 2 in thread

Searching the docs, maybe there is something you could use...
You should have a look at

bool QTreeWidgetItem::isExpanded () const
bool QTreeWidget::isItemExpanded ( const QTreeWidgetItem * item ) const
void QTreeWidgetItem::setExpanded ( bool expand )

The first and second one returns the expanded state of the current item, 
the third can set an item to be collapsed/expanded.

So the if statement could be like
if( myTreeWidget.isItemExpanded(myItem) )
myItem.setExpanded(false)

If isItemExpanded is true, then it's expanded else it's collapsed.


Dennis Guzman wrote:
> Hello dev partners,
> 
> First I have a QTreeWidget and I have in it items as groups of other
> items.
> 
> Now I don't know if setItemExpanded(the item I want to Expand/Collapse is a
> group) is a native qt function, so if is, how I can make it collapse, and
> how can I put in an "IF" sentence, like "if (item isexpanded)" or
> collapse.
> 
> 
> Any help will be great
> 
> Dennis Guzmán A
> 


--
 [ signature omitted ]