Results 1 to 2 of 2

Thread: slot with variable arguments

  1. #1
    Join Date
    Nov 2009
    Posts
    1
    Qt products
    Qt4

    Question slot with variable arguments

    Hello, I am trying to create a slot method that has variable arguments. The MOC'er does its thing but when the compiler runs it complains about syntax.

    error 2059 : syntax error : '('

    Qt Code:
    1. class Utility : public QObject {
    2. Q_OBJECT
    3. public slots:
    4. void log(char *, ...);
    5. };
    To copy to clipboard, switch view to plain text mode 

    MOC'ed code (snipped)
    Qt Code:
    1. int Utility::qt_metacall(QMetaObject::Call _c, int _id, void **_a) {
    2. //...
    3. case 0: log((*reinterpret_cast<const char *(*)>(_a[1])), (*reinterpret_cast< (*)>(_a[2]))); break;
    4. //...
    5. }
    To copy to clipboard, switch view to plain text mode 
    It looks like the MOC'er doesn't know how to handle '...'. Is there a better way to do this?

    Thanks!

  2. #2
    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: slot with variable arguments

    Slots can't use varargs. You can use QVariantList to pass a variable number of different types of arguments.
    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.


Similar Threads

  1. 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
  2. passing arguments in SLOT
    By eleanor in forum Qt Programming
    Replies: 3
    Last Post: 3rd July 2008, 21:55
  3. nmake error during .pro compiling
    By mattia in forum Installation and Deployment
    Replies: 5
    Last Post: 18th June 2008, 10:15
  4. Problem When Creating my own Slot
    By Fatla in forum Qt Programming
    Replies: 12
    Last Post: 6th June 2008, 14:44
  5. Calling a slot with arguments
    By drhex in forum Qt Programming
    Replies: 6
    Last Post: 1st May 2008, 21:22

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.