[Qt-interest] how to check which button emited signal clicked?

franki franki at franki.eu.org
Thu Jan 28 11:57:06 CET 2010


Hi,

I have QTabWidget which holds info about files that user can download, one of 
column is QPushButton set with setCellWidget, files are taken from sql.
Code looks like this:

while (itsql->q.next()) {
                QPushButton *annexPB=new QPushButton("Download");
               connect(annexPB,SIGNAL(clicked()),this,SLOT(downloadAnnex()));
                QLabel *label2=new QLabel(itsql->q.value(3).toString());
                QLabel *label3=new QLabel(itsql->q.value(1).toString());
                cp.p0_annexTable->insertRow(i);
                cp.p0_annexTable->setCellWidget(i,0,annexPB);
                cp.p0_annexTable->setCellWidget(i,1,label2);
                cp.p0_annexTable->setCellWidget(i,2,label3);
                i++;
        }

Now, how can I know which button was clicked? Each button refers to one file, 
but number of files is unknown, so how to provide information for 
downloadAnnex function which file it should download ?
I can't put any data into SLOT(downloadAnnex()) because clicked() signal does 
not provide any data...

Please give some advice
Thanks in advance

Marek



More information about the Qt-interest-old mailing list