一个int 数怎么是随机产生的呢
我在构造函数里定义:int row_first=0
然后在一个响应函数中调用他:
[code=C/C++][/code]
void EditMod::on_spinBox_valueChanged(int arg1)//spinbox开始为0
{
qDebug()<<QString::number(arg1);
qDebug()<<QString::number(row_first);
if(row_first>arg1)
{
/* for(int i=arg1;i<row_first;i++)
{
qDebug()<<"ok";
ui->tableWidget->removeCellWidget(i,0);
ui->tableWidget->removeCellWidget(i,1);
}*/
row_first=arg1;
}
else
{
row_first=arg1;
}
for(int i=0;i<arg1;i++)
{ combox1[i] = new QComboBox(this);
combox1[i]->addItem(" 1 ");
combox1[i]->addItem(" 2 ");
combox1[i]->addItem(" 3 ");
ui->tableWidget->setCellWidget(i,0,combox1[i]);
}
for(int i=0;i<arg1;i++)
{
combox2[i] = new QComboBox(this);
combox2[i]->addItem("shutdown");
combox2[i]->addItem("alarm");
combox2[i]->addItem("fire");
ui->tableWidget->setCellWidget(i,1,combox2[i]);
}
}
运行:改变spinbox的值,结果打印
"1"
"0"
"2"
"167018784"
"3"
"167054208"
"4"
"167108768"
"5"
"167043720"
"6"
"167106488"
"7"
"167130784"
"6"
"167140112"
"5"
"167154400"
"4"
"167133360"
row_firs是随机产生的了?这是为什么/?
[解决办法]
怎么可能是随机的呢?
"1"
"0"这是对一次打印的,不是0吗?
肯定是你在其他的代码里给他赋值了。