[Qt-interest] Dialog box and signal/slot question
Phil
phillor at telstra.com
Mon Nov 9 18:34:15 CET 2009
Thank you for reading this.
I've moved on somewhat from my previous question and now I'm stuck with
a signal/slot connection.
This is how I add items to a table shown on a dialog:
void Configuration::showDialog(QString str)
{
Configuration configDlg;
for(int col = 0; col < 4; col++)
{
QTableWidgetItem *item = new QTableWidgetItem(list[col +1]);
item->setTextAlignment(Qt::AlignHCenter);
configDlg.freqTableWidget->setItem(row, col, item);
}
I now want to access a particular row in the table so I've added the following
line to my Configuration constructor:
connect(freqTableWidget, SIGNAL(cellActivated(int, int)), this,
SLOT(selectRow(int, int)));
The problem is that activating a cell does not connect to the selectRow slot.
It seems to me that I need to add "configDlg" to the connect code. But
configDlg is declared in the showDialog function and is not known to the
constructor.
I've tried adding "Configuration configDlg" as a private attribute in the
Configuration header file and I've tried a pointer as well and new in the
constructor. None of these methods are correct.
The addressbook example is close to what I'm trying to achieve but it's a
little complex and I cannot relate it to my particular case.
By the way, the Configuration class is not the main window.
--
Regards,
Phil
More information about the Qt-interest-old
mailing list