QTableWidget itemDoubleClicked signal link to textEdit
-
i have a populated tableWidget and i want to select the row header upon doubleClick and grab the text in the row header then populate a textEdit with it.
i have:
@connect(ui->tableWidget, SIGNAL(itemDoubleClicked(QTableWidget*)),ui->textEdit, SLOT(on_tableWidget_itemDoubleClicked(QTableWidgetItem*)));
void on_tableWidget_itemDoubleClicked(QTableWidgetItem *item)
{
QString selectedName = item->text();
ui->textEdit->setText(selectedName);
} @
and not only is the focus not changing when i run and doubleClick the code buh nothing is happening to the textEdit... Am i missing something here? is the row header not a TableWidgetItem?? -
You should check "Signals & Slots":http://doc.qt.nokia.com/stable/signalsandslots.html
So your slot function MUST be a member of a class derived from QObject and with Q_OBJECT preprocessor defined.edit for quote:
bq. All classes that contain signals or slots must mention Q_OBJECT at the top of their declaration. They must also derive (directly or indirectly) from QObject.