PDA

View Full Version : connect not working with manually created object



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)

rakkar
20th September 2009, 03:19
I see the problem. It works if click a cell in the table, but not the column header, which is what I want. Is there a signal for this?

rakkar
20th September 2009, 03:52
Found it, it's sectionClicked on the horizontalHeader()