[提问]如何选择QDialogButtonBox的信号与槽
1、UI中设计了一个QDialogButtonBox,按钮为Cancel和Apply;
2、构造函数连接:
connect(ui->buttonBox, SIGNAL(accepted()), this, SLOT(slotButtonA()));
connect(ui->buttonBox, SIGNAL(rejected()), this, SLOT(slotButtonB()));
以上Cancel按钮能成功响应slotButtonB(),Apply按钮无响应
3、尝试改变slotButtonA()的信号
connect(ui->buttonBox, SIGNAL(clicked(QAbstractButton*)), this, SLOT(slotButtonA()));
connect(ui->buttonBox, SIGNAL(rejected()), this, SLOT(slotButtonB()));
此时则Cancel按钮是先响应了slotButtonA(),后再响应slotButtonB(),而Apply按钮能成功响应
4、自定义的槽内容为
void Test::slotButtonA()
{
QMessageBox::warning(NULL, tr("title"), tr("A"));
}
void Test::slotButtonB()
{
QMessageBox::warning(this, tr("title"), tr("B"));
}
请问应如何能使UI中的QDialogButtonBox按钮,正确地实现响应?
2、构造函数连接:
connect(ui->buttonBox, SIGNAL(accepted()), this, SLOT(slotButtonA()));
connect(ui->buttonBox, SIGNAL(rejected()), this, SLOT(slotButtonB()));
以上Cancel按钮能成功响应slotButtonB(),Apply按钮无响应
3、尝试改变slotButtonA()的信号
connect(ui->buttonBox, SIGNAL(clicked(QAbstractButton*)), this, SLOT(slotButtonA()));
connect(ui->buttonBox, SIGNAL(rejected()), this, SLOT(slotButtonB()));
此时则Cancel按钮是先响应了slotButtonA(),后再响应slotButtonB(),而Apply按钮能成功响应
4、自定义的槽内容为
void Test::slotButtonA()
{
QMessageBox::warning(NULL, tr("title"), tr("A"));
}
void Test::slotButtonB()
{
QMessageBox::warning(this, tr("title"), tr("B"));
}
请问应如何能使UI中的QDialogButtonBox按钮,正确地实现响应?
...全文
相关推荐
Designer中的QDialogButtonBox的accepted、rejected和helpRequested信号.rar
Designer中的QDialogButtonBox的accepted、rejected和helpRequested信号.rar
Designer中QDialogButtonBox确认clicked信号是哪个按钮发送的方法.rar
Designer中QDialogButtonBox确认clicked信号是哪个按钮发送的方法.rar
Designer中的QDialogButtonBox的StandardButtons标准按钮.rar
Designer中的QDialogButtonBox的StandardButtons标准按钮.rar
PyQt(Python+Qt)学习随笔:Designer中的QDialogButtonBox的ButtonRole详解.rar
PyQt(Python+Qt)学习随笔:Designer中的QDialogButtonBox的ButtonRole详解.rar
PyQt(Python+Qt)学习随笔:Designer中的QDialogButtonBox增加自定义按钮的方法.rar
PyQt(Python+Qt)学习随笔:Designer中的QDialogButtonBox增加自定义按钮的方法.rar


