Results 1 to 2 of 2

Thread: QTimer::singleshot doesn't call SLOTs with arguments

  1. #1
    Join Date
    Feb 2006
    Location
    Magdeburg
    Posts
    5
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default QTimer::singleshot doesn't call SLOTs with arguments

    hi all,

    I want to execute my function "saveTraining()" 20 seconds after another function. I suppose a SingleShot-Timer to be the right choice.

    If I call this command
    Qt Code:
    1. QTimer::singleShot( 20000, this, SLOT(saveTraining()));
    To copy to clipboard, switch view to plain text mode 
    my function "saveTraining()" is executed properly after 20 seconds. All works fine.

    But if I try to commit an argument like in this command:
    Qt Code:
    1. QTimer::singleShot( 20000, this, SLOT(saveTraining(5)));
    To copy to clipboard, switch view to plain text mode 
    my function "saveTraining(int number)" isn't executed.


    Infos:
    -I also tried to commit other arguments, like QString or QPointF without success.
    -The compiler is compiling this project without any errors or warnings
    -There is the right prototyp of my function in the .h-File
    -I also tried to commit a "Klassenvariable" without success. I don't know the right english word for "Klassenvariable". It's a variable which is declared staticly in the class so that every object of this class has this variable. Maybe "membervariable" is the right word for it.
    -Version Qt 4.1.2 Open Source


    Where is my mistake? Could it be possible that it isn't allowed to commit arguments in a SingleShot-Timer? I didn't see such an info in the documentation. I hope you can help me. Sorry for my probably bad english.

    Hulk

  2. #2
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: QTimer::singleshot doesn't call SLOTs with arguments

    You cannot put parameter values to signals and slots in the connect statement.
    You can only put parameter types, which need to match exactly for the signal and the slot (exception: a slot can have less parameters than the signal..)

    If you want one timer to emit some value and another timer to emit some different value, you can use a QSignalMapper.
    Last edited by jpn; 6th April 2006 at 12:27.
    J-P Nurmi

Similar Threads

  1. Replies: 4
    Last Post: 16th February 2009, 07:10
  2. Can we connect QTimer::SingleShot with a slot taking arguments?
    By maverick_pol in forum Qt Programming
    Replies: 4
    Last Post: 17th September 2008, 18:02

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.