Results 1 to 20 of 21

Thread: processEvents() and threads

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Dec 2007
    Posts
    40
    Thanks
    6
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11

    Default Re: processEvents() and threads

    hi correct me if i am wrong, but i understand that your problem is:

    int main(void)
    {
    QApplication app;
    //animation code
    heavyProcessingFunc();
    app.exec();
    }

    calling processEvents() with a timer started in main also does not give timer call back.
    the timer of qt also works with the eventloop so till you do an app.exec() the event loop is not started and hence you wont get timercall backs.
    if you are not allowed to change the heayProcessingFunc() you should definitely move it into another thread. or else i dont think we can figure out a way to do the animation smoothly!!!
    but then the problem in interesting and a neat final solution would be a nice thing to see...

    cheers!
    Let your work talk for you

  2. #2
    Join Date
    Feb 2009
    Location
    Noida, India
    Posts
    517
    Thanks
    21
    Thanked 66 Times in 62 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: processEvents() and threads

    well, i cant move the heavy processing code to another thread cuz there are lots of gui calls in it..and a thread cant have gui calls..i think this problem can only be solved if i get to process events of main thread from another thread..for which i couldnt find an api..any other pointers?

  3. #3
    Join Date
    Dec 2007
    Posts
    40
    Thanks
    6
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11

    Default Re: processEvents() and threads

    Quote Originally Posted by talk2amulya View Post
    well, i cant move the heavy processing code to another thread cuz there are lots of gui calls in it..and a thread cant have gui calls..i think this problem can only be solved if i get to process events of main thread from another thread..for which i couldnt find an api..any other pointers?
    does this heavy processing function call the GUI elements directly? would it not be possible to, in some way, decouple the function and the GUI elements?
    because, if it is not the case, we have a simple issue of a function which takes a lot of time being invoked in a thread! and obviously the thread does nothing but execute the function for a long time!!!
    Let your work talk for you

  4. #4
    Join Date
    Feb 2009
    Location
    Noida, India
    Posts
    517
    Thanks
    21
    Thanked 66 Times in 62 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: processEvents() and threads

    THATS the reason why i was trying to call processEvents() from another thread, thinking it would solve my problem..but evidently it doesnt save my life..

  5. #5
    Join Date
    Jan 2006
    Location
    Sta. Eugènia de Berga (Vic - Barcelona - Spain)
    Posts
    869
    Thanks
    70
    Thanked 59 Times in 57 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: processEvents() and threads

    Hi,

    Can you try to add "processEvents" calls into the process function? If you have a loop, you can add it to be called every loop iteration, ...
    Òscar Llarch i Galán

  6. #6
    Join Date
    Feb 2009
    Location
    Noida, India
    Posts
    517
    Thanks
    21
    Thanked 66 Times in 62 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: processEvents() and threads

    well, i mentioned it before also..i have tried that and that does work..although the loading icon animates intermittently..but it definitely moves..but i've been asked to find "another" way of doing it..and now i m coming to the conclusion that perhaps it cant be done in any other way, if i m not missing anything that QT provides and i m not aware of or u guys are not aware of...

  7. #7
    Join Date
    Dec 2007
    Posts
    40
    Thanks
    6
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11

    Default Re: processEvents() and threads

    this had to be! managerial decisions on how the code should execute (not meant against anyone, but I have had a fair share of these kind of things myself!!!)...
    but may be there is no way this can be achieved, unless ofcourse there is some obscure hard-to-find feature somewhere hidden in qt!!!
    Let your work talk for you

Similar Threads

  1. Once more: Threads in Qt4
    By high_flyer in forum Qt Programming
    Replies: 5
    Last Post: 9th August 2006, 18:35

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.