Results 1 to 3 of 3

Thread: Passing argument to slot.

  1. #1
    Join Date
    Aug 2011
    Location
    Portugal
    Posts
    34
    Thanks
    15
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Passing argument to slot.

    Hello,
    I'm trying to pass an argument to a slot triggered by a finished() signal.

    My code right now is this:

    download.cpp
    Qt Code:
    1. (...)
    2. connect(&fdmanager, SIGNAL(finished(QNetworkReply*)),SLOT(FileDownloadFinished(filechk,QNetworkReply*)));
    3. QNetworkRequest request(QUrl(fileurl.data()));
    4. fdmanager.get(request);
    5. (...)
    6. void download::FileDownloadFinished(QByteArray chksum, QNetworkReply *reply) {
    7. (...)
    8. }
    To copy to clipboard, switch view to plain text mode 

    download.h
    Qt Code:
    1. (...)
    2. public slots:
    3. void FileDownloadFinished(QByteArray chksum, QNetworkReply *reply);
    4. };
    5. (...)
    To copy to clipboard, switch view to plain text mode 

    The code compiles without any warnings, but when it run... I get this on the program output:
    Qt Code:
    1. Object::connect: No such slot download::FileDownloadFinished(filechk,QNetworkReply*)
    To copy to clipboard, switch view to plain text mode 

    Apparently I'm not passing the arguments correctly... How should I do it?

    Thanks in advance.

  2. #2
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: Passing argument to slot.

    You can't. You have to emit your own signal which matches this signature, or you can have a look at QSignalMapper if it could be used in your case.

  3. #3
    Join Date
    Aug 2011
    Location
    Portugal
    Posts
    34
    Thanks
    15
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Passing argument to slot.

    Quote Originally Posted by Lykurg View Post
    You can't. You have to emit your own signal which matches this signature, or you can have a look at QSignalMapper if it could be used in your case.
    Thank you for the info. I'll take a look at QSignalMapper.

Similar Threads

  1. Passing a (char) to a (int) argument - Is it safe?
    By lgb3 in forum General Programming
    Replies: 4
    Last Post: 1st October 2011, 22:17
  2. onclick event passing argument to js function
    By dyngoman in forum Qt Programming
    Replies: 0
    Last Post: 10th September 2011, 13:51
  3. Replies: 2
    Last Post: 22nd June 2010, 21:35
  4. Trouble passing an argument
    By benlyboy in forum Newbie
    Replies: 5
    Last Post: 9th May 2010, 22:49
  5. QtScript : passing array as argument into function
    By derek_r in forum Qt Programming
    Replies: 4
    Last Post: 27th October 2007, 10:46

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.