Home > Software design >  QDialogButtonBox::accepted() is protected
QDialogButtonBox::accepted() is protected

Time:10-13

I want to write my custom input dialog. I wrote following lines to handle click on OK/Cancel:

connect(buttonBox, &QDialogButtonBox::accepted,this, &MyCustomDialog::accept);

I got this error on compile:

/usr/include/qt4/QtGui/qdialogbuttonbox.h:147:10: error: 'void QDialogButtonBox::accepted()' is protected
     void accepted();

There isn't any public signal in QDialogButtonBox.

CodePudding user response:

This is not about QDialogButtonBox. It is about your Qt version. You are using Qt5 syntax for singal-slot while you have Qt4. Use this:

connect(buttonBox, SIGNAL(accepted()),this, SLOT(accept()));

accepted is a Q_SIGNALS which is protected in Qt4, so you can't use that syntax.

  • Related