Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我需要将spinBox值设置为函数之外的变量。所以在这里我有可变时间并想将其设置为spinBox值:
spinBox
void MainWindow::on_spinBox_valueChanged(int arg1) { arg1 = ui->spinBox->value(); }
我想存储arg1到时间变量。
arg1
我应该将时间定义为全局变量吗?
当旋转框值发生变化时,将on_spinBox_valueChanged使用旋转框的新值调用 。您正在尝试将该输入参数设置为旋转框值,它什么都不做,实际上已经是传入的值。您需要创建一个成员变量来存储结果。全局也可以,尽管这肯定不是一个好习惯。
on_spinBox_valueChanged