提示错误为:
form2.ui.h: In member function `virtual void Form2::add()':
form2.ui.h:45: no matching function for call to `QButtonGroup::selectedId()'
form2.cpp: In constructor `Form2::Form2(QWidget*, const char*, bool, unsigned
int)':
form2.cpp:7983: no matching function for call to `QGroupBox::setCheckable(const
bool&)'
form2.cpp:7984: no matching function for call to `QGroupBox::setChecked(const
bool&)'
make: *** [form2.o] Error 1
form2.ui.h如下:
***********************************************************************************
#include <qmessagebox.h>
#include <qfile.h>
#include <qtextstream.h>
#include <qfiledialog.h>
void Form2::re() //重填按钮,清空曾经填写的记录
{
lineEdit1->setText(""); //清空文本框
lineEdit2->setText("");
checkBox1->setChecked(false); //设置checkbox为未选择状态
checkBox2->setChecked(false);
checkBox3->setChecked(false);
checkBox4->setChecked(false);
}
void Form2::add() //添加按钮
{
if ( lineEdit1->text().isEmpty() || lineEdit2->text().isEmpty() ||
(!checkBox1->isChecked()&&!checkBox2->isChecked()&&!checkBox3->isChecked()&&
!checkBox4->isChecked())) //当信息未填写完整时,跳出消息框提醒用户继续填写
{
QMessageBox::about(this,tr("Error!"),tr("请完整填写所有信息!"));
}
else
{
QString choice=" ";
QListViewItem *item = new QListViewItem( listView1 ); //在list中新建一条记录
item->setText( 0, lineEdit3->text() ); //将信息对应填入list中相应的位置
item->setText( 1, lineEdit1->text() );
item->setText( 3, lineEdit2->text() );
item->setText( 6, lineEdit4->text() );
switch(buttonGroup1->selectedId ()) //当选择男时,将男写入list中
{ //当选择女时,将女写入list中
case 0:
item->setText( 2, radioButton1->text () );
break;
case 1:
item->setText( 2, radioButton2->text () );
break;
}
if(checkBox1->isChecked()) //若checkbox1被选中,将checkbox1的文本传给变量
choice=checkBox1->text()+" ";
if(checkBox2->isChecked()) //若checkbox2被选中,将checkbox2的文本传给变量
choice=choice + checkBox2->text()+" ";
if(checkBox3->isChecked()) //若checkbox3被选中,将checkbox3的文本传给变量
choice=choice + checkBox3->text()+" ";
if(checkBox4->isChecked()) //若checkbox4被选中,将checkbox4的文本传给变量
choice=choice + checkBox4->text();
item->setText(4,choice); //4种选项以空格隔开
switch(comboBox1->currentItem()) //将组合框被选中的当前值写入list中
{
case 0:
item->setText(5,comboBox1->currentText());
break;
case 1:
item->setText(5,comboBox1->currentText());
break;
case 2:
item->setText(5,comboBox1->currentText());
break;
case 3:
item->setText(5,comboBox1->currentText());
break;
}
}
}