问题
I have a program that opens another window and i want the old window to close. Is there some function or something that would close the window through the code but keep the other window running?
回答1:
this->close();
or
close();
Ref: http://doc.qt.digia.com/4.7/qwidget.html#close
回答2:
MyWidget *newform = new MyWidget;
newform->show();
this->hide();
回答3:
void Dialog::on_Close_clicked() // Condition for Main thread program stopping
Running Thread->closethread = true;
this->close();
void Dialog::on_Stop_clicked() // Condition For Stop Button for your particular task
{
this->close();
}
回答4:
Use signal and slot mechanism.
Whenever you want to close that window or screen emit a signal and connect this signal to the close slot of that window. This should work fine.
来源:https://stackoverflow.com/questions/11749262/qt-close-a-running-window-through-code