Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

QTreeWidget how to output selected item name.. ?



  • Hello. I have recently started getting into QT and Widgets. I have designed a UI table using QT Creator design option. I have also made a slots fr my TreeWidgets that I want to select. I did not implement any of the code myself, once I select which slot I want to, the code is being generated outside my project directory and wont let me access and see any of it.
    The slot that I have created is on_projectTreeWidget_itemPressed ( See the picture below)
    https://ibb.co/QDmyN0z
    It also generated a function in my mainwindow:
    void MainWindow::on_projectTreeWidget_itemPressed(QTreeWidgetItem *item, int column)
    {
    qDebug()<<"item"<<item<<endl;
    qDebug()<<"column"<<column<<endl;
    qDebug()<<"&item"<<&item<<endl;

    }
    I am trying to debug print a name of selected widget for example(test_main_script) but it just return some random characters and I dont know what wrong I am doing?? Can someone give me some advice please



  • int row = 0;//test_main_script data row
    qDebug()<<ui->Tablewidget->selectedItems().at(row)->data(col).toString();



  • @lukutis222 said in QTreeWidget how to output selected item name.. ?:

    &item

    This is of type QTreeWidgetItem **item probably not what you want. I'd guess you were looking for item->text() instead


Log in to reply