How to access QTreeWidget items added using qt Creator gui builder



  • I created a tree using Qt Creator and added items and children using GUI only. Now I wish to access those. I can only check which item is selected using current Item.text property, but how to access the one's which are not selected.
    Actually I wish to change the currently selected item to another item, something like
    @if(ui->treewidget->currentItem()->text(0)!="something")
    // then it should select the item named something
    @



    • To change the data in the current item use QTreeWidgetItem::setText().
    • To access the data in arbitrary cells use the QTreeWidget::model() to generate QModelIndex values and then use QAbstractItemModel::data()/setData()
    • To change which item is the current item use QtreeWidget::setCurrentItem()
    • To find another item by its content use QTreeWidget::findItems().

Log in to reply
 

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