我怎么知道按钮是否被切换?
How can I know wether a pushbutton is toggled or not?
如图所示,我有 96 个按钮,最初是绿色的。
单击按钮 ( toggled(bool
) ) 后它变为红色。
我想要做的是在单击“确定”按钮后禁用所有红色按钮。
我该怎么做?
如果“确定”按钮关闭了这个 window,我应该怎么做才能在我再次打开 window 时保存修改(禁用的按钮)!
在 qt 中,togglebuttons 是普通按钮,它们继承了 qAbstractbutton
https://doc.qt.io/archives/qt-4.8/qabstractbutton.html#checked-prop
在那里你可以使用 bool isChecked() 方法:
This property holds whether the button is checked.
Only checkable buttons can be checked. By default, the button is
unchecked.
所以我想,您在某种数组中有网格,您可以在 for 循环中浏览...
所以你可以这样做:
for(...)
{
ui->x->setEnabled(!ui->x->isChecked());
}
如图所示,我有 96 个按钮,最初是绿色的。
单击按钮 ( toggled(bool
) ) 后它变为红色。
我想要做的是在单击“确定”按钮后禁用所有红色按钮。
我该怎么做?
如果“确定”按钮关闭了这个 window,我应该怎么做才能在我再次打开 window 时保存修改(禁用的按钮)!
在 qt 中,togglebuttons 是普通按钮,它们继承了 qAbstractbutton
https://doc.qt.io/archives/qt-4.8/qabstractbutton.html#checked-prop
在那里你可以使用 bool isChecked() 方法:
This property holds whether the button is checked.
Only checkable buttons can be checked. By default, the button is unchecked.
所以我想,您在某种数组中有网格,您可以在 for 循环中浏览...
所以你可以这样做:
for(...)
{
ui->x->setEnabled(!ui->x->isChecked());
}