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

How to impliment signal and slot when click on checkbox in first row of the QTreeWidgetitem



  • I have following code and I want to impliment signal and slot

    int main(int argc, char **argv)
    {
    QApplication app(argc, argv);
    QTreeWidget table;
    table.setColumnCount(3);

    QTreeWidgetItem* item = new QTreeWidgetItem();
    item->setFlags(item->flags() | Qt::ItemIsUserCheckable | Qt::ItemIsSelectable);
    item->setText(0,QString::number(0));
    item->setText(1,QString::number(1));
    item->setText(2,QString::number(2));

    item->setCheckState(1,Qt::Checked);
    item->setCheckState(2,Qt::Checked);

    table.addTopLevelItem(item);

    table.show();
    return app.exec();
    }



  • @Qt-Enthusiast

    You can't simply implement something in main and expect to get it to work with signal and slots. You need a class which inherits from QObject in order to benefit from signal slot mechanism.

    I suggest that you are examining the examples e.g. http://doc.qt.io/qt-5/qtwidgets-itemviews-editabletreemodel-example.html
    There you have a good start for some experiments. Using the debugger will help you to understand some more details about the functionality.


Log in to reply