• 3317阅读
  • 0回复

[提问]关于QSettings的问题 [复制链接]

上一主题 下一主题
离线nobodycp
 

只看楼主 正序阅读 楼主  发表于: 2015-10-29
           程序中有两个radioButton,选择radioButton_1时Frame_1的Enable状态为true,Frame_2为false
                                                      选择radioButton_2时Frame_1为false,Frame_2为true
           没有使用QSettings时正常工作,但是使用QSettings后,程序运行一次,Frame的Enable状态就固定为程序上次运行关闭时的状态,再点击
           radioButton_1和2都无法改变Frame的状态,用qDebug看过两个radioButton的槽函数,两个槽函数都能被正常调用,但里面设置Frame状态的
           命令都失效了。

void MainWindow::on_radioButton_2_clicked()
{
    ui->frame->setEnabled(false);
    ui->frame_2->setEnabled(true);
}
QSettings的设置:settings->setValue(now->objectName() + ".enabled", qobject_cast<QWidget *>(now)->isEnabled());
                              qobject_cast<QWidget *>(now)->setEnabled(settings->value(now->objectName() + ".enabled").toBool());
快速回复
限100 字节
 
上一个 下一个