Hello,
I've sort of got it working, but still missing something.
As you can see the results I'm getting from "if (dlg.exec() == QDialog::Accepted)" are
always from the reject choice.
Help please.
Regards
Results:-
reject "returnded - ok" - OK button
reject "returnded - rej" - cancel button
reject "returnded - rej" - Dialog 'X' button
reject "returnded - rej" - menu exit
Results:-
reject "returnded - ok" - OK button
reject "returnded - rej" - cancel button
reject "returnded - rej" - Dialog 'X' button
reject "returnded - rej" - menu exit
To copy to clipboard, switch view to plain text mode
calling Dialog:-
divideoptionsdlg dlg(passedData, parent);
if (dlg.
exec() == QDialog::Accepted) {
qDebug() << "accept " << returned; //ok button
}
else
{
qDebug() << "reject " << returned; //cancel button
}
calling Dialog:-
divideoptionsdlg dlg(passedData, parent);
QObject::connect( &dlg, SIGNAL(returnData(QString)), this, SLOT(gotReturnedData(QString)) );
if (dlg.exec() == QDialog::Accepted)
{
qDebug() << "accept " << returned; //ok button
}
else
{
qDebug() << "reject " << returned; //cancel button
}
To copy to clipboard, switch view to plain text mode
callled Dialog:-
B1->setGeometry( this->width() / 2, this->height() - 30, (this->width() / 2) - 5, 30 );
QObject::connect( B1,
SIGNAL(accepted
()),
this,
SLOT(onOKclickedSlot
()) );
QObject::connect( B1,
SIGNAL(rejected
()),
this,
SLOT(reject
()) );
void divideoptionsdlg::onOKclickedSlot()
{
emit returnData(data);
this->close();
}
divideoptionsdlg::~divideoptionsdlg()
{
emit returnData(data);
}
callled Dialog:-
QDialogButtonBox *B1 = new QDialogButtonBox(this);
B1->setGeometry( this->width() / 2, this->height() - 30, (this->width() / 2) - 5, 30 );
B1->addButton(tr("OK"), QDialogButtonBox::AcceptRole);
B1->addButton(tr("Cancel"),QDialogButtonBox::RejectRole);
QObject::connect( B1, SIGNAL(accepted()), this, SLOT(onOKclickedSlot()) );
QObject::connect( B1, SIGNAL(rejected()), this, SLOT(reject()) );
void divideoptionsdlg::onOKclickedSlot()
{
QString data = "returnded - ok";
emit returnData(data);
this->close();
}
divideoptionsdlg::~divideoptionsdlg()
{
QString data = "returnded - rej";
emit returnData(data);
}
To copy to clipboard, switch view to plain text mode
Bookmarks