[英]How can put an event on a QButtonGroup button in c++?
My buttonGroup is already load with 45 buttons i want do anything after a button is clicked this is my code: 我的buttonGroup已经加载了45个按钮,单击按钮后我想做任何事情,这是我的代码:
#include "escogerpuesto.h"
#include "ui_escogerpuesto.h"
#include <iostream>
EscogerPuesto::EscogerPuesto(QWidget *parent) :
QWidget(parent),
ui(new Ui::EscogerPuesto)
{
ui->setupUi(this);
ui->buttonGroup->connect(ui->buttonGroup, SIGNAL(clicked()), this, SLOT(asientoClickeado));
}
EscogerPuesto::~EscogerPuesto()
{
delete ui;
}
void EscogerPuesto::asientoClickeado()
{
std::cout<<"click en asiento";
}
Button group contains signal with parameter QAbstractButton* or int, so you should connect this signal with slot which has an appropriate parameter. 按钮组包含带有参数QAbstractButton *或int的信号,因此您应将此信号与具有适当参数的插槽连接。
ui->buttonGroup->connect(ui->buttonGroup, SIGNAL(buttonClicked(QAbstractButton*)),
this, SLOT(your_slot(QAbstractButton* ));
Or you can connect each button with some slot. 或者,您可以将每个按钮连接到某个插槽。
You can read more here: http://harmattan-dev.nokia.com/docs/library/html/qt4/signalsandslots.html 您可以在此处阅读更多信息: http : //harmattan-dev.nokia.com/docs/library/html/qt4/signalsandslots.html
and here http://harmattan-dev.nokia.com/docs/library/html/qt4/qbuttongroup.html 在这里http://harmattan-dev.nokia.com/docs/library/html/qt4/qbuttongroup.html
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.