Results 1 to 5 of 5

Thread: Use of QTimer

  1. #1
    Join Date
    Jun 2009
    Posts
    29
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Use of QTimer

    Is there any way to call parameterized function with timeout(), making it a class or somehow?

  2. #2
    Join Date
    Feb 2009
    Location
    Lexington, KY
    Posts
    8
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Use of QTimer

    If you want a particular object to handle the timeout, just connect the timeout signal to a slot in the object you want to handle the timeout. Any special parameters can be encapsulated in the object as member variables.

    Bill.

  3. #3
    Join Date
    Jun 2009
    Posts
    29
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Use of QTimer

    I can use QTimer as:
    QTimer::singleShot(1500, this, SLOT(crossCapture()));

    But, can this be used like:
    QTimer::singleShot(1500, this, SLOT(crossCapture(int,int)));

    If so, please give me an example, how?

  4. #4
    Join Date
    Jan 2008
    Location
    Poland
    Posts
    687
    Thanks
    4
    Thanked 140 Times in 132 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Use of QTimer

    You can't do this. You can connect signal to slot where slot has less params than signal, but can't do it the other way - because from where that slot should take values for missing arguments?
    I would like to be a "Guru"

    Useful hints (try them before asking):
    1. Use Qt Assistant
    2. Search the forum

    If you haven't found solution yet then create new topic with smart question.

  5. #5
    Join Date
    Feb 2009
    Location
    Lexington, KY
    Posts
    8
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Use of QTimer

    You could sub-class QTimer and write a new singleShot method that takes the two additional ints that you want to pass as parameters, and stores them in instance variables. It would intercept the standard timeout signal and emit a new timeout signal passing the stored values as parameters.

    Bill.

Similar Threads

  1. Replies: 8
    Last Post: 27th March 2013, 11:51
  2. Extending QTimer()
    By rishid in forum Qt Programming
    Replies: 3
    Last Post: 7th August 2009, 01:59
  3. Seg fault using QTimer on 64-Bit Ubuntu
    By Mike in forum Qt Programming
    Replies: 0
    Last Post: 2nd July 2009, 08:03
  4. QThread/QObject and QTimer
    By swiety in forum Qt Programming
    Replies: 2
    Last Post: 25th January 2008, 08:37
  5. Replies: 5
    Last Post: 6th March 2007, 05:34

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.