[solved]connect: No such slot QItemDelegate::invalidData()
-
Hi,
I tried to connect signals from a object to the function declared in MyDeleagate which inherits QsqlRelationalTableDelegate
@MyDelegate::MyDelegate(QObject *parent) : QSqlRelationalDelegate(parent)
{
blankCheck = new BlankCheck();
reset();
QObject::connect(blankCheck, SIGNAL(invalidEntry()), this, SLOT(invalidData()));
}@@void MyDelegate::invalidData()
{
qDebug() << "Invalid Entry";
}@and the class declaration is
@class MyDelegate : public QSqlRelationalDelegate
{
public:
MyDelegate(QObject *parent);
QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option,
const QModelIndex &index) const;
void setEditorData(QWidget *editor, const QModelIndex &index) const;
void setModelData(QWidget *editor, QAbstractItemModel *model,
const QModelIndex &index) const;
void reset();private:
BlankCheck *blankCheck;private slots:
void invalidData();};@
It is compiled, but while running the program, following error occurs
Object::connect: No such slot QItemDelegate::invalidData() in mydelegate.cpp:15
Why I can't connect these?
Thanking You,
Ras -
You forgot the Q_OBJECT macro in your declaration.
Without this macro, signals, slots and introspection features will not work.
-
Hi,
Thank you, but when using Q_OBJECT marco following errors while compiling! Why?mydelegate.cpp:10: error: undefined reference to `vtable for MyDelegate'
-
Did you re-run qmake after adding Q_OBJECT?
-
Thanks Solved the issue.