QTreeWidget



  • How can I obtain the number of the tol level items?



  • You could do the children() option, that would give the direct children of the TreeWidget, not the children of the children.
    Or Iterate over the TreeWidget and store all the items in a separate list?
    What do you want to achieve?? What do you really need to do? We might come up with other options.
    Greetz



  • Hi, I have more than one thing to do. My situation is a QTreeWidget with 22 item. Some items have subitems some others not.

    1. I have to get the number of top level items.
    2. Clicking on a PushButton I have to exchange the current item with the item before or after.

    Do you know how I can do it?



  • Like I mentioned, use the children() option or to make it really easy: RTFM:

    @
    int topLevelItemCount() const
    @
    It is there in the docs................
    Then to switch the two toplevel items when the button is pressed, check out this function:
    @
    QTreeWidgetItem * takeTopLevelItem(int index)
    @


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.