Results 1 to 3 of 3

Thread: retrieving signal name in a slot

  1. #1
    Join Date
    Sep 2008
    Posts
    1
    Qt products
    Qt4
    Platforms
    Windows

    Default retrieving signal name in a slot

    Hi guys,

    I'm connecting different signals of different objects to one slot.
    By invocation of this slot I want to retrieve the object name, the
    class name and the signal name of the "invoking" object.

    The object name is simply retrievable by QObject::sender()->objectName()
    The class name is also simple: QObject::sender()->metaObject()->className().

    But I don't know how to get the signal name.

    This signal name is very important, because I'm programming a
    GUI element (QDesigner plugin) to which the signals of other GUI elements
    (like QPushButton.clicked(), ...) are connected. If one clicks for example
    on the QPushButton B1 then my plugin forwards the Information
    "B1 of type QPushButton has been clicked" via TCP to another application.
    So it's important to habe the object name, the class name and the signal name.

    Had someone just a similar problem and knows the solution?

    Thanks a lot,
    Sebastian

  2. #2
    Join Date
    Sep 2008
    Location
    New York
    Posts
    90
    Thanks
    13
    Thanked 4 Times in 4 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: retrieving signal name in a slot

    How about use a global string to store the most recent signal name?
    Before sending out signal, changed the string name; then in slot function, you can display the string.


    Quote Originally Posted by Baschterl View Post
    Hi guys,

    I'm connecting different signals of different objects to one slot.
    By invocation of this slot I want to retrieve the object name, the
    class name and the signal name of the "invoking" object.

    The object name is simply retrievable by QObject::sender()->objectName()
    The class name is also simple: QObject::sender()->metaObject()->className().

    But I don't know how to get the signal name.

    This signal name is very important, because I'm programming a
    GUI element (QDesigner plugin) to which the signals of other GUI elements
    (like QPushButton.clicked(), ...) are connected. If one clicks for example
    on the QPushButton B1 then my plugin forwards the Information
    "B1 of type QPushButton has been clicked" via TCP to another application.
    So it's important to habe the object name, the class name and the signal name.

    Had someone just a similar problem and knows the solution?

    Thanks a lot,
    Sebastian

  3. #3
    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: retrieving signal name in a slot

    You can't access signal name trough Qt --- it doesn't store it anywhere. You might look up the stack trace and use debugging information to obtain that name.

Similar Threads

  1. Connect signal from base to slot of sub-sub-object
    By donglebob in forum Qt Programming
    Replies: 15
    Last Post: 30th October 2008, 19:54
  2. Replies: 12
    Last Post: 18th September 2008, 15:04
  3. Signal & Slot editor
    By Ishark in forum Qt Tools
    Replies: 4
    Last Post: 28th May 2008, 15:20
  4. signal and slot across threads having event loop
    By travis in forum Qt Programming
    Replies: 6
    Last Post: 5th November 2007, 23:56
  5. signal slot conection using a string, not a SLOT
    By rianquinn in forum Qt Programming
    Replies: 6
    Last Post: 5th February 2006, 18:52

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.