Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Update: Forum Guidelines & Code of Conduct


    Qt World Summit: Early-Bird Tickets

    [Solved]Closing window error

    General and Desktop
    1
    2
    1291
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • R
      ranger0 last edited by

      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());
      this->close();
      break;
      default:
      mostraerro(erro.text(),janela);
      }
      ...
      @

      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.

      1 Reply Last reply Reply Quote 0
      • R
        ranger0 last edited by

        Problem solved using:
        @
        this->setAttribute(Qt::WA_QuitOnClose);
        QApplication::postEvent(this, new QEvent(QEvent::Close),Qt::HighEventPriority);
        @

        Regards.

        1 Reply Last reply Reply Quote 0
        • First post
          Last post