Results 1 to 4 of 4

Thread: Incompatible sender/receiver arguments

  1. #1
    Join Date
    Dec 2009
    Posts
    65
    Thanks
    10
    Thanked 4 Times in 4 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows Android

    Default Incompatible sender/receiver arguments

    I have 2 classes A and B

    class A has a signal emitMessage(QString)
    class B has a slot showMessage(QString, int)

    is there a way to connect these two with constant int value, something like

    connect(A, SIGNAL(emitCritical(QString, 5)), B, SLOT(showMessage(QString, int)));

    or
    connect(A, SIGNAL(emitCritical(QString)), B, SLOT(showMessage(QString, 5)));

    I know that if signal had more arguments, they will be ignored in slot, but is it possible to have default values for slot arguments
    Last edited by davidovv; 6th May 2011 at 10:07.

  2. #2
    Join Date
    Jan 2009
    Location
    Germany
    Posts
    131
    Thanks
    11
    Thanked 16 Times in 16 Posts
    Qt products
    Qt3 Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Incompatible sender/receiver arguments


  3. #3
    Join Date
    May 2010
    Location
    Romania
    Posts
    1,021
    Thanks
    62
    Thanked 260 Times in 246 Posts
    Qt products
    Qt5
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: Incompatible sender/receiver arguments

    Quote Originally Posted by davidovv View Post
    ... is it possible to have default values for slot arguments
    Yes, but if you have a function with default argument let's call it void foo(QString &s, int i = 10) how do you call it with default i value? Like this: foo(some_qstring); so delete the magic 5 from the connection.

  4. The following user says thank you to Zlatomir for this useful post:

    davidovv (29th September 2011)

  5. #4
    Join Date
    Dec 2009
    Posts
    65
    Thanks
    10
    Thanked 4 Times in 4 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows Android

    Default Re: Incompatible sender/receiver arguments

    I kind of tried that before i started this thread but i wrote
    in declaration showMessage(QString, int)
    in definition showMessage(QString msg, int interval = 5)

    the correct answer was
    in declaration showMessage(QString, int = 5)
    in definition showMessage(QString msg, int interval)

    now i can connect them with
    connect(A, SIGNAL(emitCritical(QString)), B, SLOT(showMessage(QString)));

    Thanks for your help,

Similar Threads

  1. QCoreApplication::postEvent: Unexpected null receiver
    By mortoray in forum Qt Programming
    Replies: 3
    Last Post: 14th November 2010, 22:14
  2. Incompatible MSVCRT.dll
    By ahmdsd_ostora in forum Installation and Deployment
    Replies: 10
    Last Post: 22nd August 2010, 09:02
  3. Receiver
    By Salazaar in forum Newbie
    Replies: 1
    Last Post: 5th May 2007, 19:26
  4. QCoreApplication::postEvent: Unexpected null receiver
    By merlvingian in forum Qt Programming
    Replies: 6
    Last Post: 13th March 2007, 20:25
  5. postEvent() to a non-existing receiver
    By Artschi in forum Qt Programming
    Replies: 7
    Last Post: 1st June 2006, 14:44

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
  •  
Qt is a trademark of The Qt Company.