The following code sets up a list of checkboxes.
QWidget *w = new QWidget(this);
w->setFixedSize(300,200);
QVBoxLayout *vbox = new QVBoxLayout;
foreach(QString filt, filters){
QCheckBox *checkbox = new QCheckBox(filt, this);
checkbox->setChecked(true);
vbox->addWidget(checkbox);
connect(this, SIGNAL(statechanged(int)), this, SLOT(cbstate(int)));
}
w->setLayout(vbox);
w->show();
The idea is that when the user checks or unchecks an item, it will emit a signal.
In the header file, I have included the following in the private slots:
void cbsate(int state);
And in the cpp file, I have declared this:
void MainWindow::cbstate(int state){
if(state == 0){
//unchecked
QMessageBox::information(this, "Unchecked", "You have unchecked this box");
}
else if (state == 2){
//checked
QMessageBox::information(this, "Checked", "You have checked this box");
}
}
I'm now getting an error of
no 'void MainWindow::cbstate(int)' member function declared in class 'MainWindow'
Any ideas? Am I going about this correctly? Thanks.