PDA

View Full Version : how to show an app if it manually hide



jthacker
26th March 2010, 13:50
hi guys,

i have an app.

i have made a function in my main file of the app.

in which i want show and hide app automatically after every 5 sec.



while(1){
app.show();
sleep(5);
app.hide();
sleep(5);
};


but once it is minimized it is not showing anything

what to do?

TMan
26th March 2010, 14:02
First of all, you should call hide() or show() on your mainwindow, not on the application.

Supposing you do that, note that while doing this in main (i.e. outside of the event loop), means that you did not even enter the event loop, thus calling show() will probably not work correctly.

Thus, you should implement this functionality in your mainwindow class. I suggest defining two slots, for instance myHide and myShow.

myShow would then:

show();
QTimer::singleShot (5000, this, SLOT(myHide()));


myHide would do something similar but reversed obviously. Furthermore, you should call either myHide or myShow once by yourself.