PDA

View Full Version : Q3Checklistitem stateChange function not working



Ketan Shah
21st May 2011, 13:51
hii,i want to perform some action when the checkbox is checked or unchecked, can ny1 tell me how can i do this...below is my code...
its not happening anything when i checked or unchecked d checkbox..


public slots:
void stateChange (bool);

signals:
void statusChange (ext*, bool);



ui->listView->setResizeMode( Q3ListView::LastColumn );
ui->listView->addColumn( "Extension" );

QStringList fileTypes;



fileTypes << "_*.dll" ;
QDir dir("E:/qtpro/ext");
dir.setNameFilters(fileTypes);
QStringList files = dir.entryList();


for (int i = 0; i < files.size(); ++i)
{

QFileInfo fileInfo = files.at(i);

new Q3CheckListItem(ui->listView,QString("%1").arg(fileInfo.fileName()), Q3CheckListItem::CheckBox );

}

}

void ext::stateChange(bool value)
{
emit statusChange(this, value);
}


plz help...

stampede
22nd May 2011, 09:32
Where do you connect the signal ?

Ketan Shah
23rd May 2011, 07:06
I am trying to connect it through the CheckListItem...
When i Check or uncheck the CheckListItem it should call the stateChange function,which in turn emit the statusChange signal...

stampede
23rd May 2011, 08:38
What I meant was "show us the code where you make the connection".

for (int i = 0; i < files.size(); ++i)
{

QFileInfo fileInfo = files.at(i);

new Q3CheckListItem(ui->listView,QString("%1").arg(fileInfo.fileName()) , Q3CheckListItem::CheckBox );

}
You are creating new check list items, but you are not connecting the signal, at least not in this part of code. Should be more like:

for (int i = 0; i < files.size(); ++i){
QFileInfo fileInfo = files.at(i);
Q3CheckListItem * item = new Q3CheckListItem(ui->listView,QString("%1").arg(fileInfo.fileName()) , Q3CheckListItem::CheckBox );
connect(item, SIGNAL(...), ...); // figure out the details yourself :)
}