How to connect default QDialogButtonBox
-
Hi folks,
in my class I am using a QDialogButtonBox. The UI has been made with QtCreator.
How do I connect those buttons using the NEW syntax?
I tried the code below but I get "error: no matching member function for call to 'connect'#include "mycomments.h" #include "ui_mycomments.h" MyComments::MyComments(QWidget *parent) : QDialog(parent), ui(new Ui::MyComments) { ui->setupUi(this); connect(this, ui->dialogButtonBox->button(QDialogButtonBox::Apply), this, &MyComments::slotApplyComment); } MyComments::~MyComments() { delete ui; } void slotApplyComment() { }
-
Hi
Your connect is a bit odd.
Should not be likeconnect(ui->dialogButtonBox->button(QDialogButtonBox::Apply), &QPushButton::pressed, this, &MyComments::slotApplyComment);
-
-
Hi
Your connect is a bit odd.
Should not be likeconnect(ui->dialogButtonBox->button(QDialogButtonBox::Apply), &QPushButton::pressed, this, &MyComments::slotApplyComment);
@mrjj said in How to connect default QDialogButtonBox:
connect(ui->dialogButtonBox->button(QDialogButtonBox::Apply), &QPushButton::pressed, this, &MyComments::slotApplyComment);
This gives me:
mycomments.cpp:10:68: error: incomplete type 'QPushButton' named in nested name specifier
qdialog.h:51:7: note: forward declaration of 'QPushButton' -
@ademmler said in How to connect default QDialogButtonBox:
qdialog.h:51:7: note: forward declaration of 'QPushButton'
c++ basics - when you want to use a class you have to make sure the compiler sees it by e.g. including the header where it's defined.
-
@ademmler said in How to connect default QDialogButtonBox:
qdialog.h:51:7: note: forward declaration of 'QPushButton'
c++ basics - when you want to use a class you have to make sure the compiler sees it by e.g. including the header where it's defined.
@Christian-Ehrlicher You where faster ... just got it and wanted to delete my post ...
But honestly - c++ error messages are not very clear ;-) -
Apart from this - why not simply using QDialogButtonBox::accepted()