Important: Please read the Qt Code of Conduct -

Can't send events to a Modal QDialog!

  • I have class that generates QKeyEvent and sends them to the qApp->activeWidget(), but when I'm in a modal QDialog qApp->activeWidget() returns only 0!

    I've tried to do qApp->activeModalWidget() but I also get 0, so I can't send "fake" keyboard events to my Dialog, so I just stays there. I can't even close it ¬¬

  • I've implemented an "exec()" like function, that doesn't leaves the main event-loop, but still it does!

    @int QSelectionDialog::getSelection(void){
    while ( !isDone ){
    int ret_val;
    ret_val = eleccion->text().toInt();
    if ( ret_val > last->count() )
    ret_val = 0;

        return ret_val;


    What am I doing wrong?

Log in to reply