Destroy all windows

  • hi frends,
    please how I can destroy all windows with puchbutton

  • Qt Champions 2017

    How do you create them?
    Normally, you can just use the variable to delete them again.
    There is also close() to close them but it all depends on what you are doing :)

  • @mrjj I create them with QT disigner

  • Qt Champions 2017

    ok, but how do you open/show then?
    just put the variables as member in .h
    and keep them around after you new the forms.

    i assume you do something like

    MyForm * form=new MyForm(this) ?

  • If the Form pointer is named for example "formPointer" just delete it in the on_Pushbutton function(slot in header file) :
    delete formPointer;
    formPointer = nullptr;
    Then Form will disappear. So You can not have it back, but if You want just to hide it and show it again on some action.
    You can do this:
    And if You want to have it back You can do this:

  • <joke>QObject::connect(button,SIGNAL(clicked()),vandal,SLOT(throwBricks()));</joke>

  • @ayoubBD

    connect(ui->pushButton, &QPushButton::clicked, qApp, &QApplication::closeAllWindows);

Log in to reply

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