Results 1 to 11 of 11

Thread: QTimeWaster

  1. #1
    Join Date
    Apr 2010
    Posts
    152
    Thanks
    5
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Angry QTimeWaster

    Does setting the QTimer interval to 0 help anyhow? I've been struggling with creating an idle event for a rendering loop and everytime I got a different problem. 4.8 fixed one problem I had before but now I'm facing another. Whenever I add my graphics window custom control to the form, the timer is no more triggered until I either resize or move the window. Should I go back to MFC and leave open-source buggy libraries? Come on, gimme a break!!!

  2. #2
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: QTimeWaster

    Quote Originally Posted by qtoptus View Post
    Does setting the QTimer interval to 0 help anyhow?
    Yes, the QTimer fires immediately when the program returns to the Qt event loop. Any slot attached to the timeout() signal gets run at that time.
    I've been struggling with creating an idle event for a rendering loop and everytime I got a different problem. 4.8 fixed one problem I had before but now I'm facing another. Whenever I add my graphics window custom control to the form, the timer is no more triggered until I either resize or move the window.
    How about trying to help yourself. Sounds like your "rendering loop" is doing things the wrong way. We cannot guess the creative way you have achieved this effect with absolutely no information from you.
    Should I go back to MFC and leave open-source buggy libraries?
    Yes... especially if all you are going to do is complain that a perfectly good programming framework does not meet your needs.
    Come on, gimme a break!!!
    http://www.bbc.co.uk/cbbc/shows/gimme-a-break

  3. #3
    Join Date
    Apr 2010
    Posts
    152
    Thanks
    5
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QTimeWaster

    I cannot understand why sometimes it's taken personal...anyway

    Sounds like your "rendering loop" is doing things the wrong way
    How? Example?

    Yes, the QTimer fires immediately when the program returns to the Qt event loop. Any slot attached to the timeout() signal gets run at that time.
    Not always, not perfectly.

    We cannot guess the creative way you have achieved this effect with absolutely no information from you.
    It sounds like Qt requires achieving stuff in a "creative" way in order to work.

    Cute!

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

    Default Re: QTimeWaster

    qtimer works without needing to resize/move a window, so it suggests there is something wrong with your control that keeps the event queue from emptying - qtimer (0) fires when the event queue is empty.

    you have not provided any code at all.

    you only asked two questions in your op -

    does setting timer to 0 help?
    should you go back to mfc?

    How do you expect us to answer with the information you have provided?
    If you have a problem, CUT and PASTE your code. Do not retype or simplify it. Give a COMPLETE and COMPILABLE example of your problem. Otherwise we are all guessing the problem from a fabrication where relevant details are often missing.

  5. #5
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: QTimeWaster

    Quote Originally Posted by qtoptus View Post
    I cannot understand why sometimes it's taken personal...anyway
    I wasn't taking anything personally. I was merely pointing out that the best way to get an answer to a question about doing X with Y is to provide some information about what X is, how you are trying to do X, what you expected to happen, what actually happens, and why you think that Y is at fault. X and Y apply to your problem and Qt just the same as they would to your problem and MFC, .Net, or Lisp. Simply stating that Y is broken and threatening to take your bat and ball and go home is not going to get you anywhere.
    Quote Originally Posted by ChrisW67
    Sounds like your "rendering loop" is doing things the wrong way
    How? Example?
    There are many more ways to do something wrong or sub-optimally than I have had dinners. Amleto has one general mechanism by which your code can break things. How are we supposed to know how you are doing anything? You have yet to tell us anything about your code, your "rendering loop", and how you are achieving the unusual effects you describe... only that you think it is Qt's fault. Yes, they are unusual behaviours coming from your program, but only you seem to have them. They are a huge number of people, myself included, who have had no issues with zero QTimers. When we can see what you are doing then we could possibly tell you how to do it better.
    Quote Originally Posted by ChrisW67
    Yes, the QTimer fires immediately when the program returns to the Qt event loop. Any slot attached to the timeout() signal gets run at that time.
    Not always, not perfectly.
    Prove it. Provide an example of how it doesn't work [docs=QTimer.html#details]as documented[/qtimer].
    It sounds like Qt requires achieving stuff in a "creative" way in order to work.
    Programming in general has a creative element. Qt requires you to use Qt in the way it designed to be used. This is absolutely no different to MFC, .Net or any other programming tool or framework.

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

    Default Re: QTimeWaster

    Chris, it's in the docs that qtimer will silently discard timeout events/signals in some circumstances. I don't know if that is what the op was referring to or not.

  7. #7
    Join Date
    Apr 2010
    Posts
    152
    Thanks
    5
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QTimeWaster

    Sometimes frustration of a problem puts the blame on the framework...

    After investigating the problem, I could find that adding a graphics widgets has nothing to do with the timer not being triggered. It only happens when making the widget a Direct3D capable window.
    I pass the window handle of the widget to Direct3D stuff which resides in a DLL.

  8. #8
    Join Date
    Apr 2010
    Posts
    152
    Thanks
    5
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QTimeWaster

    Another finding, if it's an OpenGL window then it works fine. All I'm doing is a simple form using VS plugin and QtDesigner, add a class derived from widget to the form, and inside the form I have the QTimer. This timer also calls boost::chrono timer functions.

  9. #9
    Join Date
    Apr 2010
    Posts
    152
    Thanks
    5
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QTimeWaster

    Ok now problem solved when setting the timer anything but 0. Setting it to 1 works fine...weird...

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

    Default Re: QTimeWaster

    Quote Originally Posted by qtoptus View Post
    Ok now problem solved when setting the timer anything but 0. Setting it to 1 works fine...weird...
    there is a fundamental difference in behaviour of qtimer when the timeout is changed from 0 to 1. Just because it works, doesn't mean the original problem now gone.
    If you have a problem, CUT and PASTE your code. Do not retype or simplify it. Give a COMPLETE and COMPILABLE example of your problem. Otherwise we are all guessing the problem from a fabrication where relevant details are often missing.

  11. #11
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QTimeWaster

    It would really help if you shared some of your code. A good guess would be some routines in the d3d dll are screwing up something in regard to what Qt expects.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


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.