Results 1 to 3 of 3

Thread: error: no matching function for call to ‘QTimer:

  1. #1
    Join Date
    Feb 2012
    Location
    Armenia/Yerevan
    Posts
    400
    Thanks
    15
    Thanked 16 Times in 15 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11

    Default error: no matching function for call to ‘QTimer:

    I need to set a timer in my serial class, so when the timer triggers, it calls
    a slot. I get the following error when I build the program:

    error: no matching function for call to ‘QTimer::singleShot(int, rsxxx* const, bool)’
    Here's the code segment:

    Qt Code:
    1. void rsxxx::DieselSwitchOff()
    2. {
    3. if(!DieselSwitchOff_1())
    4. {
    5. qDebug() << "Diesel failed to switch off..";
    6. }
    7.  
    8. QTimer::singleShot(3000, this, DieselSwitchOff_2());
    9. }
    To copy to clipboard, switch view to plain text mode 

    how should DieselSwitchOff be declared? as a public slot or a class member suffices?
    also note that the DieselSwitchOff_2 return bool.
    I pass the this pointer, as I want to call the singleShot in my rs485 class.

  2. #2
    Join Date
    May 2011
    Posts
    239
    Thanks
    4
    Thanked 35 Times in 35 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Symbian S60

    Default Re: error: no matching function for call to ‘QTimer:

    When you look at QTimer class reference, you may notice that the last parameter is int the function call is in the examples wrapped inside a SLOT() makro, so do that and make it a public slot. I guess there may be another problem of rsxxx not being based on QObject, which is needed for that argument.

  3. #3
    Join Date
    May 2012
    Posts
    136
    Thanks
    2
    Thanked 27 Times in 24 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: error: no matching function for call to ‘QTimer:

    If the class is not an QObject it is not possible to send the class as an argument to singleShot

    The slot may be a private slot thats not a problem but maybe try:
    QTimer::singleShot(3000, this, SLOT(DieselSwitchOff_2()));

    What version of Qt are you using
    Qt3 doesn't have the singleShot function (it uses timer->start(int,bool) the bool is for singleshot)
    Qt4 does have it
    Last edited by StrikeByte; 21st May 2012 at 15:53.

Similar Threads

  1. Replies: 1
    Last Post: 19th March 2011, 10:57
  2. about no matching function for call to
    By Alain Delon in forum General Programming
    Replies: 1
    Last Post: 5th March 2011, 21:30
  3. Replies: 1
    Last Post: 1st December 2010, 11:02
  4. no matching function for call to setupUi
    By ctote in forum Qt Programming
    Replies: 2
    Last Post: 30th January 2010, 15:20
  5. No Matching function to call...
    By weepdoo in forum Qt Programming
    Replies: 2
    Last Post: 7th November 2008, 17:30

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.