qt slots and signalls autoconnecting

254 Views Asked by At

I am using Qt 5.2.1. I read this, and that - it doesn't cover my case. I have QSqlTableModel , and a window that uses it. I want to react on its dataChanged signal:

void QAbstractItemModel::​dataChanged(const QModelIndex & topLeft, const QModelIndex & bottomRight, const QVector<int> & roles = QVector<int> ())

So I initialize the model in my windowClass constructor like this:

kontrahentModel = new QSqlTableModel(this);

And heres the slot declaration:

void on_kontrahentModel_dataChanged(const QModelIndex & topLeft, const QModelIndex & bottomRight, const QVector<int> & roles = QVector<int> ());

Same number of arguments - but it results in the infamous

QMetaObject::connectSlotsByName: No matching signal for (...)

What did I miss? Does it only work for GUI signals?

1

There are 1 best solutions below

0
On BEST ANSWER

I fixed it by accident while writing this question... My model was missing a name. When I added

kontrahentModel->setObjectName("kontrahentModel");

All worked like a charm...

BUT - "there is no rose without a thorn". When assigning a parent for the model, an old problem returns - described here: QSqlQueryModel with a parent - app crash