Connect try use slot of parent



  • Hi!

    header:
    @
    #ifndef BUHTABLEMODEL_H
    #define BUHTABLEMODEL_H

    #include <QStandardItemModel>

    class BuhTableModel : public QStandardItemModel
    {
    public:
    BuhTableModel(QObject *parent = 0);

    private slots:
    void changed(QStandardItem *item);
    };

    #endif // BUHTABLEMODEL_H
    @

    code:
    @
    #include "buhtablemodel.h"

    BuhTableModel::BuhTableModel(QObject parent)
    : QStandardItemModel(parent)
    {
    connect(this, SIGNAL(itemChanged(QStandardItem
    )), this, SLOT(changed(QStandardItem*)));
    }

    #include <QDebug>

    void BuhTableModel::changed(QStandardItem *item)
    {
    qDebug() << item->data().toString();
    }
    @

    Where is my mistake?

    QObject::connect: No such slot QStandardItemModel::changed(QStandardItem*)



  • The class definition is missing the "Q_OBJECT":http://qt-project.org/doc/qt-5/qobject.html#Q_OBJECT macro.



  • thanks!
    I completely forgot about that macro.


Log in to reply
 

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