How to get both index and selected item at asame time in qtreewidget?

  • Hi i have a problem...In my tree widget i wanted to know the selected (actually checked) item index
    for that i used signal

    Now i wanted along with index i needed current item too, for that one more signal i got

    but i wanted a signal to get index and current item at a same can i do that?
    please help me...i tried in manual but didnt understand how can i get both index and current item at same time...

  • Moderators

    You could use a two staged approach, if you really need to have both at the same time.
    Receive the model index through first connection of signal clicked to your slot. Subsequently, you can "retrieve a pointer to your item": and send the signal with both as you require.
    However, the question is, if you still require to have both sent in a signal.

  • this is a two step problem, i think:
    QTreeWidget::selectedItems ()
    this will return in your case a QList with one item
    and the
    QTreeWidget::indexFromItem ( QTreeWidgetItem * item, int column = 0 ) will get the index for you

Log in to reply

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