PDA

View Full Version : Abort QDialog in the constructor



Tino
29th July 2009, 13:49
Hi,
In a QDialog constructor I do that:


try {
QLabel *lbls = new QLabel[numLbls]; //numLbls is passed as parameter
} catch(std::bad_alloc e) {
// How I can abort this QDialog and avoid to be show?
}

How I can abort this QDialog and avoid to be show?

airbites
29th July 2009, 14:58
I don't understand. How can you add that try/catch block in QDialog constructor if it is Qt base class?

wysota
29th July 2009, 15:36
The constructor doesn't show the dialog. A call to show() or exec() does that. You can override it by reimplementing showEvent() and hiding the component there, by intercepting the call that shows the dialog or simply by not calling show() or exec() at all.