Results 1 to 7 of 7

Thread: Problem with QSlider's signal

  1. #1
    Join Date
    Dec 2006
    Posts
    426
    Thanks
    8
    Thanked 18 Times in 17 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Problem with QSlider's signal

    Hi,

    I have a slider with valueChanged signal connecting to a quick computation.

    When I move the slider crazily fast. I have to call QCoreApplication:rocessEvents() to immediately update the slider movement, then emit valueChanged.

    The computation can't catch up the speed and not all valueChanged's are received.

    However, when I stop sliding, it starts to process those singals and end up the last slider value doesn't much the computation result.

    For instance, I finally stop at value 53, but the computation process the previous missed signal, such as 32. So the last input slider value doesn't match the computation.

    How can I solve this problem?

    Thanks!

    Hi,

    I have a slider with valueChanged signal connecting to a quick computation.

    When I move the slider crazily fast. I have to call QCoreApplication:rocessEvents() to immediately update the slider movement, then emit valueChanged.

    The computation can't catch up the speed and not all valueChanged's are received.

    However, when I stop sliding, it starts to process those singals and end up the last slider value doesn't much the computation result.

    For instance, I finally stop at value 53, but the computation process the previous missed signal, such as 32. So the last input slider value doesn't match the computation.

    How can I solve this problem?

    Thanks!


    Added after 24 minutes:


    It looks like I solve it!

    In computation, I did

    Qt Code:
    1. if ( slider->value() != value ) {
    2. return;
    3. }
    To copy to clipboard, switch view to plain text mode 

    Wonder if this is the right way...
    Last edited by lni; 17th September 2011 at 09:50.

  2. #2
    Join Date
    Sep 2011
    Posts
    1,245
    Thanks
    3
    Thanked 127 Times in 126 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Problem with QSlider's signal

    no, the computation shouldnt be in the gui thread. then you wont need to worry about processevents

  3. #3
    Join Date
    Dec 2006
    Posts
    426
    Thanks
    8
    Thanked 18 Times in 17 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Problem with QSlider's signal

    Quote Originally Posted by amleto View Post
    no, the computation shouldnt be in the gui thread. then you wont need to worry about processevents
    Actually, I am using QtConcurrent::map() in my computation, which is in other threads. That is why I have to processEvent to update the slider movement immediately...

    Now, I just spend 12 hours to find a crash when doing fast moving in Windows, but no crash in Linux.

    I should be using QCoreApplication::sendPostedEvents(), not QCoreApplication:rocessEvents().

    Can you believe it took me 12 hours for me to find that darn 1 line difference!

    It keeps complains "Qt has caught an exception thrown from an event handler. Throwing exceptions from an event handler is not supported in Qt. You must reimplement QApplication::notify() and catch all exceptions there."

    I did re-implement notify and caught the exception, but it still crashes no matter I return true/false after exception! I had also searched all over the world and downloaded Microsoft's useless Application Verifier for nothing!

  4. #4
    Join Date
    Sep 2011
    Posts
    1,245
    Thanks
    3
    Thanked 127 Times in 126 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Problem with QSlider's signal

    so what was throwing?

  5. #5
    Join Date
    Apr 2011
    Posts
    39
    Thanks
    1
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Problem with QSlider's signal

    Qt is smart enough and fast to catch the each and every value change event,
    so that is not with Qt that it is missing any value change event.
    please check your code there might be some critical code that make Qt behave like that,
    otherwise even single value change event is caught by Qt,
    so do 1 thing make a sample program with slider and check only the functionality what you want with slider in that sample app.

  6. #6
    Join Date
    Dec 2006
    Posts
    426
    Thanks
    8
    Thanked 18 Times in 17 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Problem with QSlider's signal

    Quote Originally Posted by amleto View Post
    so what was throwing?
    Don't know. I try to catch
    std::exception, QString, QtConcurrent::Exception, QtConcurrent::UnhandledException, std::string, con char*, none of them caught it, it is caught by catch( ... ) and then die with the complain...

  7. #7
    Join Date
    Sep 2011
    Posts
    1,245
    Thanks
    3
    Thanked 127 Times in 126 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Problem with QSlider's signal

    I suggest you debug it and turn 'break on exceptions' on.

Similar Threads

  1. Replies: 7
    Last Post: 15th June 2011, 05:59
  2. QSlider and sliderReleased() signal
    By Luc4 in forum Qt Programming
    Replies: 1
    Last Post: 19th June 2010, 18:37
  3. Replies: 4
    Last Post: 4th March 2010, 11:44
  4. Replies: 2
    Last Post: 6th July 2009, 12:53
  5. QSlider problem
    By sincnarf in forum Qt Programming
    Replies: 1
    Last Post: 10th October 2007, 01:07

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.