ユーザーがチェックボックスをチェックおよびチェック解除するための有効なシグナルスロットメカニズムがあります。
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(checkbox, SIGNAL(stateChanged(int)), this, SLOT(cbstate(int)));
}
w->setLayout(vbox);
w->show();
void MainWindow::cbstate(int state){
if(state == 0){
//unchecked
QMessageBox::information(this, "blah", "You have unchecked this box");
}
else if (state == 2){
//checked
QMessageBox::information(this, "blah", "You have checked this box");
}
}
私の問題の説明は非常に簡単です。関数に渡す必要がありQString filt
ますcbstate
。
これを行う方法がわかりませんか?スロットに追加しようとすると、エラーがスローされます。