[SOLVED] QDialog how to catch all close events?



  • I have qDialog and on the @closeEvent(QCloseEvent *e) {}@ I can only catch if the user close the dialog from close button (x) only and not if the user cliched Ok or Cancel or hit the esc key. what event will do all this? I wist to emit a signal on the close event but reading the doc i've realised that the dialog will be hidden and not close on esc, Ok - accept(), or Cancel - reject(). hmm.. any good advise on how to catch all?



  • ok I've solved myself I do not know if this is the best option but here it is a work around or a solution :P

    in dialog construct I have
    @connect(this, SIGNAL(accepted()), this, SLOT(onCloseDialog()));
    connect(this, SIGNAL(rejected()), this, SLOT(onCloseDialog()));
    connect(this, SIGNAL(dialogIsClosing()), this, SLOT(onCloseDialog()));@

    and this
    @void DialogName::closeEvent(QCloseEvent *event){
    emit dialogIsClosing();
    event->accept();
    }@

    and then
    @void DialogName::onCloseDialog{
    //what ever you want on the form hide or closing or rejected or accepted
    }@

    do not forget to add in the h file the emited signal for the close event.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.