gpt4 book ai didi

c++ - 如何从qt中的单选按钮获取值?

转载 作者:行者123 更新时间:2023-11-30 05:43:50 33 4
gpt4 key购买 nike

我在 groupbox 中有很多单选按钮,我想获取选中的单选按钮的文本数据。但是我不想写很多“else if”,我的意思是;

if (ui->radiobutton->isChecked)
// method's
else if (ui->radiobutton->isCheked)
// method's
..
..

有什么方法可以让我了解在特定的组框中选中了哪个单选按钮?如果可能的话,你能给我举个例子吗?

最佳答案

您可以使用 QButtonGroup 作为父级:http://doc.qt.io/qt-5/qbuttongroup.html#checkedButton

QAbstractButton * QButtonGroup::checkedButton() const

Returns the button group's checked button, or 0 if no buttons are checked.

See also buttonClicked().

关于c++ - 如何从qt中的单选按钮获取值?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30081160/

33 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com