Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. [Solved]Closing window error

[Solved]Closing window error

Scheduled Pinned Locked Moved General and Desktop
2 Posts 1 Posters 1.4k Views
  • 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 Offline
    R Offline
    ranger0
    wrote on last edited by
    #1

    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
    0
    • R Offline
      R Offline
      ranger0
      wrote on last edited by
      #2

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

      Regards.

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved