Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. Screen switching with Scrolling effect
QtWS25 Last Chance

Screen switching with Scrolling effect

Scheduled Pinned Locked Moved Mobile and Embedded
13 Posts 2 Posters 5.7k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • V Offline
    V Offline
    varunjajee
    wrote on 26 Oct 2011, 13:39 last edited by
    #1

    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
    Varun

    Edit: removed useless series of *** from the topic title; Andre

    1 Reply Last reply
    0
    • J Offline
      J Offline
      Jupiter
      wrote on 26 Oct 2011, 14:08 last edited by
      #2

      well imo animation framework is the best way. but you could try using QTimeline and changing the widget position.
      or a scroll area where the scrolling is animated.

      1 Reply Last reply
      0
      • V Offline
        V Offline
        varunjajee
        wrote on 26 Oct 2011, 17:27 last edited by
        #3

        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).

        1 Reply Last reply
        0
        • J Offline
          J Offline
          Jupiter
          wrote on 26 Oct 2011, 17:59 last edited by
          #4

          well normally animation framework doesn't freeze the gui thread. can you post your code?

          1 Reply Last reply
          0
          • V Offline
            V Offline
            varunjajee
            wrote on 27 Oct 2011, 08:25 last edited by
            #5

            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.

            1 Reply Last reply
            0
            • J Offline
              J Offline
              Jupiter
              wrote on 27 Oct 2011, 08:37 last edited by
              #6

              so you run the code on a single cpu application? or does the worker thread in case of an event needs information of the gui thread? Perhaps a bit dirty but can't you sleep the worker thread during the animation?

              1 Reply Last reply
              0
              • V Offline
                V Offline
                varunjajee
                wrote on 27 Oct 2011, 08:43 last edited by
                #7

                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().

                1 Reply Last reply
                0
                • J Offline
                  J Offline
                  Jupiter
                  wrote on 27 Oct 2011, 08:47 last edited by
                  #8

                  have you tried to send a signal to the thread, and in the threads slots a call to QThread::currentThread()->wait() ?

                  1 Reply Last reply
                  0
                  • V Offline
                    V Offline
                    varunjajee
                    wrote on 27 Oct 2011, 08:54 last edited by
                    #9

                    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.

                    1 Reply Last reply
                    0
                    • J Offline
                      J Offline
                      Jupiter
                      wrote on 27 Oct 2011, 08:58 last edited by
                      #10

                      i think you'll have to sleep the thread instead of waiting. you can read more about that in the Doc

                      1 Reply Last reply
                      0
                      • V Offline
                        V Offline
                        varunjajee
                        wrote on 27 Oct 2011, 09:14 last edited by
                        #11

                        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.

                        1 Reply Last reply
                        0
                        • J Offline
                          J Offline
                          Jupiter
                          wrote on 27 Oct 2011, 09:35 last edited by
                          #12

                          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

                          1 Reply Last reply
                          0
                          • V Offline
                            V Offline
                            varunjajee
                            wrote on 27 Oct 2011, 15:33 last edited by
                            #13

                            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

                            1 Reply Last reply
                            0

                            3/13

                            26 Oct 2011, 17:27

                            topic:navigator.unread, 10
                            • Login

                            • Login or register to search.
                            3 out of 13
                            • First post
                              3/13
                              Last post
                            0
                            • Categories
                            • Recent
                            • Tags
                            • Popular
                            • Users
                            • Groups
                            • Search
                            • Get Qt Extensions
                            • Unsolved