I am trying to create a very basic dialog with Qt:
QDialog *inputDialog = new QDialog(g.ParentWidget);
QVBoxLayout *layout = new QVBoxLayout(inputDialog);
inputDialog->setWindowTitle(to_qstring(p_strTitle));
inputDialog->setLayout(layout);
QDialogButtonBox *buttonBox = new QDialogButtonBox(
QDialogButtonBox::Cancel | QDialogButtonBox::Ok, inputDialog);
layout->addWidget(buttonBox);
QObject::connect(buttonBox, &QDialogButtonBox::accepted, inputDialog, &QDialog::accept);
QObject::connect(buttonBox, &QDialogButtonBox::rejected, inputDialog, &QDialog::reject);
inputDialog->setModal(true);
if (inputDialog->exec() != QDialog::Accepted) {
return gcnew array<int>(0);
}
Where g.ParentWidget is a QWidget from elsewhere. This code is in a static method, outside of a class.
When I run this, I get:
QObject::connect: signal not fount in QDialogButtonBox
I tried looking for similar issues but I only found answers for trivial issues with old Qt syntax, or when signals: was missing, which is not the case there.
Any idea what I am doing wrong? What could be causing this?
This code is called within a C++/CLR project, in a piece of codes that gets called from C#, but I have no issue with similar stuff using QMessageBox.
since you did not specify the compiler, OS, and I also encountered such an error, I advise you to switch to the old syntax,
QObject::connect(buttonBox, &QDialogButtonBox::accepted, inputDialog, &QDialog::accept);
QObject::connect(buttonBox, &QDialogButtonBox::rejected, inputDialog, &QDialog::reject);
change to
QObject::connect(buttonBox, SIGNAL(accepted()), inputDialog, SLOT(accept()));
QObject::connect(buttonBox, SIGNAL(rejected()), inputDialog, SLOT(reject()));
such a permutation solved my problem
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With