How to hide/show the widgets/interfaces
-
Hi,
I am trying to hide the window after some time using the below code, but the window is never shown .
always i am getting the output asbq. Starting /home/user/untitled-build-desktop/untitled...
Hiding....how to to hide/show the widgets.
@
#include <QtGui/QApplication>
#include "mainwindow.h"MainWindow *mPtr;
int main(int argc, char *argv[])
{
QApplication a(argc, argv);MainWindow w; mPtr = &w; w.show(); sleep(1); w.hidewin();
return a.exec();
}
@@
#include "mainwindow.h"
#include <QDebug>
extern MainWindow *mPtr;MainWindow::MainWindow(QWidget *parent)
: QMainWindow(parent)
{
}MainWindow::~MainWindow()
{}
void MainWindow::hidewin()
{
qDebug()<<"Hiding....";
mPtr->hide();
}@
-
Add the hiding code, and the timer (use QTimer, not the sleep() function!) to your main window class. Currently, you are doing all this before the event loop is started (a.exec()).