Important: Please read the Qt Code of Conduct -

[Solved]Closing window error

  • Folks,

    I´m working at a muilti-window program and a want to close a child window in case of a specific error.

    Let me show you a piece of code:

    switch (erro.number())
    case 1205:
    mostraerro("Este registro está sendo editado por outro usuário no momento. Aguarde a finalização para"
    " acessar o registro.",janela->parentWidget());

    The "this->close();" statement is called before myapp->exec();
    This window still is running.

    I´ve tryed:
    delete this; //Whole application crashes
    QApplication::sendEvent(this,new QEvent(QEvent::Close)) //Nothing happens
    QApplication::sendEvent(this,new QEvent(QEvent::Quit)) //Nothing happens
    QApplication::sendEvent(this->parent(),new QEvent(QEvent::Close)) //Whole application crashes
    QApplication::sendEvent(this->parent,new QEvent(QEvent::Close)) //Whole application crashes
    QApplication::quit() //Nothing happens
    QApplication::close() //Nothing happens

    Any idea of how could I prevent this window of been opened?

    Best regards.

  • Problem solved using:
    QApplication::postEvent(this, new QEvent(QEvent::Close),Qt::HighEventPriority);


Log in to reply