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

QTreeWidget Signal and slot



  • Hi... after populated my QTreeWidget
    at the end, i write this:

    connect(ui->treeWidgetWiFis,SIGNAL(itemClicked(QTreeWidgetItem *,int)),this,SLOT(apri_connessione(QTreeWidgetItem*)));
    

    and

    void MainWindow::apri_connessione(QTreeWidgetItem *item)
    {
        qDebug()<<item;
    }
    

    but i have error,
    then i added in MainWindow.h, in private slot:

    void apri_connessione();
    

    but not resolve.... this is the error...
    error: out-of-line definition of 'apri_connessione' does not match any declaration in 'MainWindow'...

    Any help ?

    Thank you...
    Francesco



  • Yes, it doesn't match with function signature. apri_connessione(QTreeWidgetItem*) and you have added void apri_connessione();



  • How to fix ?

    EDIT:

    if in design make right click in QTreeWidget -> go to slot -> itemClicked()
    not work!
    with
    error: ‘QTreeWidgetItem’ has not been declared
    void on_treeWidgetWiFis_itemClicked(QTreeWidgetItem *item, int column);
    ^~~~~~~~~~~~~~~



  • @darkstaring said in QTreeWidget Signal and slot:

    QTreeWidgetItem

    include header #include <QTreeWidgetItem>



  • @TobbY said in QTreeWidget Signal and slot:

    #include <QTreeWidgetItem>

    already included

    EDIT:
    but not in mainwindow.h....
    thank you... now works


Log in to reply