rakkar
20th September 2009, 03:11
QObject::connect isn't working for me if I create the object in C++. It does work if I add it in QT designer though. Doesn't make sense. What am I doing wrong?
CPP:
QTableView *tableWidget = new QTableView(this);
tableWidget->setObjectName(QString::fromUtf8("tableView"));
tableWidget->setModel(&model);
tableWidget->setAttribute(Qt::WA_DeleteOnClose, true);
tableWidget->setSelectionMode(QAbstractItemView::SingleSelectio n);
tableWidget->setSelectionBehavior(QAbstractItemView::SelectColu mns);
QObject::connect(tableWidget, SIGNAL(clicked(QModelIndex)), this, SLOT(on_tableView_clicked(QModelIndex)));
Header file:
public slots:
void on_tableView_clicked(QModelIndex idx);
When I run it it says:
QMetaObject::connectSlotsByName: No matching signal for on_tableView_clicked(QModelIndex)
CPP:
QTableView *tableWidget = new QTableView(this);
tableWidget->setObjectName(QString::fromUtf8("tableView"));
tableWidget->setModel(&model);
tableWidget->setAttribute(Qt::WA_DeleteOnClose, true);
tableWidget->setSelectionMode(QAbstractItemView::SingleSelectio n);
tableWidget->setSelectionBehavior(QAbstractItemView::SelectColu mns);
QObject::connect(tableWidget, SIGNAL(clicked(QModelIndex)), this, SLOT(on_tableView_clicked(QModelIndex)));
Header file:
public slots:
void on_tableView_clicked(QModelIndex idx);
When I run it it says:
QMetaObject::connectSlotsByName: No matching signal for on_tableView_clicked(QModelIndex)