1、首先拖动一个checkBox按钮放在界面上,然后就是需要,选择转到槽中的槽函数,如下,选择这个

Qt CheckBox选中与未选中的使用

2、代码部分:

 1 void MainWindow::on_checkBox_stateChanged(int arg1)
 2 {
 3     //第一种
 4     if(arg1 == 2)
 5     {
 6         qDebug()<<"表示被选中1";
 7     }
 8     else if(arg1 == 0)
 9     {
10         qDebug()<<"表示未被选中";
11     }
12  
13     //第二种
14     bool status =ui->checkBox->isChecked();
15     qDebug()<<"status"<<status;
16     if(status == true)
17     {
18         qDebug()<<"表示被选中2";
19  
20     }
21     else if(status == false)
22     {
23         qDebug()<<"表示未被选中2";
24     }
25 }

结果如下: 

 Qt CheckBox选中与未选中的使用

相关文章:

  • 2022-12-23
  • 2021-12-28
  • 2022-12-23
  • 2021-09-30
  • 2022-12-23
  • 2021-11-08
  • 2021-06-21
猜你喜欢
  • 2022-12-23
  • 2022-01-10
  • 2022-12-23
  • 2022-12-23
  • 2021-07-06
  • 2022-01-22
  • 2021-07-09
相关资源
相似解决方案