I'm working on a QT application. In it the user can create several objects, each one will be added to a list. In the next step the user shall position the objects. The choice which one of the objects shall be positioned, shall be made by clicking QRadioButtons (seems logical as QRadioButtons added to a QGroupbox ensure that only one of them is active).
我正在做QT应用程序。用户可以在其中创建多个对象,每个对象将被添加到列表中。在下一步,用户应该定位对象。选择哪个对象应该被放置,应该通过单击QRadioButtons(似乎合理的是QRadioButtons添加到QGroupbox中,以确保其中只有一个是活动的)进行。
The problem is I can't find a signal that allows me tell which radio button is active or was clicked. I already connected all radio buttons to one slot, but all I get is a boolean value. How can I get the sender of the signal? Or what would be the standard way to achieve my goal?
问题是我找不到一个信号可以告诉我哪个单选按钮是激活的还是被点击的。我已经将所有单选按钮连接到一个槽上,但得到的只是一个布尔值。我怎样才能得到信号的发送者?或者达到目标的标准方式是什么?
2 个解决方案
#1
3
QObject::sender is a bit too abstract. Try QButtonGroup::buttonClicked
sender是有点抽象的。尝试QButtonGroup::buttonClicked
#2
1
You can get the sender of the signal using... QObject::sender() method within your slot!
您可以使用…获取信号的发送方。QObject: sender()方法位于您的槽中!
#1
3
QObject::sender is a bit too abstract. Try QButtonGroup::buttonClicked
sender是有点抽象的。尝试QButtonGroup::buttonClicked
#2
1
You can get the sender of the signal using... QObject::sender() method within your slot!
您可以使用…获取信号的发送方。QObject: sender()方法位于您的槽中!