Results 1 to 5 of 5

Thread: Signals and Slots (with structure as parameters)

  1. #1
    Join Date
    Nov 2006
    Posts
    4
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Signals and Slots (with structure as parameters)

    Hi

    Is there any way to pass structure as parameters for signals and slots

    thanks,
    vishwa.

  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: Signals and Slots (with structure as parameters)

    Yes, Qt just has to be made aware of the type. See Q_DECLARE_METATYPE and qRegisterMetaType.
    J-P Nurmi

  3. #3
    Join Date
    Nov 2006
    Posts
    4
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Signals and Slots (with structure as parameters)

    here is my senario

    I have a struct
    struct SourceDoneParams_t
    {
    int eventType;
    char* url;
    };

    Q_DECLARE_METATYPE(mmafwrapper::SourceDoneParams_t );

    connected signal/slot something like this
    connect(this, SIGNAL(applySourceDone(const mmafwrapper::SourceDoneParams_t)), this,
    SLOT(onApplySourceDone(const mmafwrapper::SourceDoneParams_t)));

    And I am getting error whenever signal is emmited

    QObject::connect Cannot Queue arguments of type 'mmafwrapper::SourceDoneParams_t'

  4. #4
    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: Signals and Slots (with structure as parameters)

    From Q_DECLARE_METATYPE:
    Note that if you intend to use the type in queued signal and slot connections, you also have to call qRegisterMetaType() since such connections are resolved at runtime.
    J-P Nurmi

  5. The following user says thank you to jpn for this useful post:

    vishwanath (22nd November 2006)

  6. #5
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Signals and Slots (with structure as parameters)

    Quote Originally Posted by vishwanath View Post
    struct SourceDoneParams_t
    {
    ...
    char* url;
    };
    Remember that when you send something through a queued connection Qt creates a copy of it, so watch out for that pointer.

  7. The following user says thank you to jacek for this useful post:

    sunil.thaha (23rd November 2006)

Similar Threads

  1. Nested signals and slots
    By vishva in forum Qt Programming
    Replies: 2
    Last Post: 18th August 2006, 09:47
  2. help with signals and slots
    By superutsav in forum Qt Programming
    Replies: 3
    Last Post: 4th May 2006, 12:49
  3. Signals and Slots in dll
    By ankurjain in forum Qt Programming
    Replies: 8
    Last Post: 29th March 2006, 08:12
  4. Order of signals and slots
    By Morea in forum Newbie
    Replies: 1
    Last Post: 26th February 2006, 22:09
  5. Problem with Signals and Slots
    By Kapil in forum Newbie
    Replies: 11
    Last Post: 15th February 2006, 11:35

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.