#include#include #include int main(int argc, char *argv[]) { QApplication a(argc, argv); QWidget window; window.resize(250, 150); QPushButton button("Hide", &window); button.move(50, 50); QObject::connect(&button, &QPushButton::clicked, &window, &QWidget::hide); window.show(); return a.exec(); }
#includeIn this example, the widget is hidden after a delay of 5 seconds using the QTimer::singleShot function. This function is part of the Qt package library.#include #include int main(int argc, char *argv[]) { QApplication a(argc, argv); QWidget window; window.resize(250, 150); QTimer::singleShot(5000, &window, &QWidget::hide); window.show(); return a.exec(); }