Undefined reference error
-
wrote on 28 Sept 2017, 15:17 last edited by
Hi,
I have this setItemDelegateForColumn line:QSqlTableModel* fixModel = new QSqlTableModel(this); fixModel->setTable ("Items"); fixModel->setEditStrategy (QSqlTableModel::OnRowChange); fixModel->setSort (2, Qt::DescendingOrder); fixModel->select (); ui->tableView_Fix->setModel (fixModel); ui->tableView_Fix->setItemDelegateForColumn (4, new MaterialDelegate(this)); ui->tableView_Fix->setItemDelegateForColumn(2, new FixViewDelegate(this)); ui->tableView_Fix->setItemDelegateForColumn (3, new WhatFixViewDelegate(this));
Since I added MaterialDelegate I get this error:
undefined reference to `MaterialDelegate::MaterialDelegate(QObject)'*
I read it might be a bug, but how can I go around it and assign the delegate? -
@gabor53 said in Undefined reference error:
MaterialDelegate::MaterialDelegate(QObject)'
It says it dont have such constructor.
Show the class definition.
-
@gabor53 said in Undefined reference error:
MaterialDelegate::MaterialDelegate(QObject)'
It says it dont have such constructor.
Show the class definition.
wrote on 28 Sept 2017, 15:58 last edited by@mrjj
materialdelegate.h:#ifndef MATERIALDELEGATE_H #define MATERIALDELEGATE_H #include <QComboBox> #include <QObject> #include <QString> #include <QSqlQuery> #include <QStyledItemDelegate> #include <QVBoxLayout> #include <QWidget> class MaterialDelegate : public QStyledItemDelegate { Q_OBJECT public: QSqlDatabase db; explicit MaterialDelegate(QObject* parent = Q_NULLPTR); QWidget* createEditor(QWidget* parent, const QStyleOptionViewItem& option, const QModelIndex& index) const; void setEditorData(QWidget* editor, const QModelIndex& index) const; void updateEditorGeometry(QWidget* editor, const QStyleOptionViewItem& option, const QModelIndex& index) const; void setModelData(QWidget* editor, QAbstractItemModel* fixModel, const QModelIndex& index) const; signals: public slots: }; #endif // MATERIALDELEGATE_H
-
Hi
seems fine.
Delete all files in your build folder and run qmake and rebuild all. -
wrote on 28 Sept 2017, 16:27 last edited by
Hi @gabor53
this
is probably derived from aQObject *
and you assume implicit conversion. But theexplicit
keyword in theMaterialDelegate
contructor does not allow for it: http://en.cppreference.com/w/cpp/language/explicit-Michael.
-
Hi,
Might be a silly question but did you implement that constructor ?
On a side note, there's not need for that
db
member variable. -
Hi,
Might be a silly question but did you implement that constructor ?
On a side note, there's not need for that
db
member variable. -
wrote on 29 Sept 2017, 03:06 last edited by
I completely deleted and recreated materialdelegate and now it work. Still don't know what was wrong with the previous file.
1/9