jcraig
13th July 2007, 20:48
Here's an easy one...I'm running Qt 4.3 on Red Hat. My dialog contains a QTextEdit. When the user presses OK, I need to make sure that the data in the QTextEdit is valid. Since I used Qt Designer to make the dialog, it has a QDialogButtonBox. I have connected the "clicked" signal to a slot which checks the size of the QTextEdit. If the size is adequate, I call "accept()" otherwise the slot just returns. The problem is that the dialog disappears even when accept() is not called. If I use the reject() function, the dialog still disappears.
Below is some code...thanks for any help or ideas.
Joel
DataSourceDlg :: DataSourceDlg()
{
connect(buttonBox, SIGNAL(clicked(QAbstractButton*)), this, SLOT(checkValues(QAbstractButton*)));
}
void DataSourceDlg :: checkValues(QAbstractButton* button)
{
if (button->text() == "Cancel")
{
accept(); // dismiss dialog with user click on Cancel
} else {
if (nodeLineEdit->text() > 3) {
accept(); // dismiss dialog with valid data
}
}
return; // invalid data do not dismiss dialog
}
Below is some code...thanks for any help or ideas.
Joel
DataSourceDlg :: DataSourceDlg()
{
connect(buttonBox, SIGNAL(clicked(QAbstractButton*)), this, SLOT(checkValues(QAbstractButton*)));
}
void DataSourceDlg :: checkValues(QAbstractButton* button)
{
if (button->text() == "Cancel")
{
accept(); // dismiss dialog with user click on Cancel
} else {
if (nodeLineEdit->text() > 3) {
accept(); // dismiss dialog with valid data
}
}
return; // invalid data do not dismiss dialog
}