Screen switching with Scrolling effect
-
Hi All,
I'm developijng a QT UI application. where in, The main Screen is shown on the launch of QT application. And later on button press event the Second Screen has to be shown and so on.
But to switch the screens from Screen 1 to Screen 2 the scrolling effects has to be show to the user, the scrolling effect can be from moving first to second from left to right(or from right to left).
As of now i have implemented using QT animation framework.
can any one please suggest me If there is any other way to achive this ?
Any suggestion on this is highly appreciated.
Thanks in Advance
VarunEdit: removed useless series of *** from the topic title; Andre
-
Thanks for your inputs, I could implement changing of screen using the widget scrolling without using Animation framework. this solved a problem which i was facing in my application( chocking of UI thread).
-
I will not be able to post the code. But i can explain you the scenario.
Basically, I have a multiThreaded application UI Thread with higher priority and Worker thread with NormalPriority. The Worker thread continuously listens to the events from other applications throught out the life time.
When i start an animation of switching the screen by setting the animation duration of setDuration(1500); the animation happens smoothly in the UI thread. only if the worker thread does not receive any events. And I can see the chocking effect in the animation if the worker thread receives any event form other applications during the animation.
The reason is, While the UI thread is animating it switches to the worker thread if the worker thread receives an event resulting in chocking effect in the UI.
If i use the scrolling of widgets instead of animation. than in this case the UI thread does not switch to the workder thread untill it process all the events in its event queue. resulting in smooth scrolling. To achive this I'm scrolling 10 pixel ever time in a event loop. so that i can see the smooth scrolling.
Please do suggest me if you have any other scenarios(or other way) which i can try ? So that i can see smooth animation with out chocking effects.
-
Yes, It is a single application but the worker thread interacts with other application to get the information about the device, etc etc. I tried to sleep the worker thread but it did not work.
I tried calling workerThred->wait(5000) from the main UI thread but this is blocking my main UI thread for 5000 mili seconds and not the worker thread, I suppose this is because worker thread was created on main UI Thread.
And faced the similar issues when i called the Sleep(). -
Yes, I had tried this out yesterday. but some how the animation was not that smooth.
I was getting an error/Message :- QThread tried to wait on itself. I could not understand what was this message. Was it an error ? And i could not really understand whether the thread was waiting or not.
-
thanks for your suggestions again.
I had spent good amount of time on this. But at last got puzzled. Sleep() is a protected memebr function and can not be called directly.
To call sleep() I will have to derive a class say -MyThread from QThread.
but when i post the event from one thread to other thread i will have to post the event on QObject whcih shoule be running in Worker QThread. to achive this i will have to call MoveToThread().And now when i send the postevent() from UI thread to worker thread. The QObject event loop in the worker thread receives the event. And in QObject to access its thread i will have to use thread() which returns QThread not MyThread.Since Sleep() being a protected member wont be able to access it. do i need to typecast from QThread to MyThread and access sleep() ? I havn't tried this ? I wonder will this work or not.
-
so do you actually derive from QThread in your app or not?
and if you send a signal to you thread f.e. sleep(int) to the thread slot onSleep(int) you can just call "your" member function sleep(int) without any cast. and you don't have to post events to the threads, signals are fine
-
I can call the sleep() from the run method. But i was wondering this might not be a clean design. I will look into this at later point of time. if you come across any other information regarding simillar issues than please keep me posted