Results 1 to 3 of 3

Thread: how to know which button emit the signal?

  1. #1
    Join Date
    Nov 2007
    Posts
    41
    Thanks
    12
    Qt products
    Qt4
    Platforms
    Windows

    Question how to know which button emit the signal?

    hi, everybody
    i have 3 button each of them emit the clicked() signal and that signal emit one slot
    called writeToLineEdit() and i want to pass an argument to that slot to know which button
    emit the signal but i know that the signal must has parameters just like it's slot
    how can i know the button the emit the signal???
    thank you.

  2. #2
    Join Date
    Nov 2007
    Posts
    3
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: how to know which button emit the signal?

    Look at QObject::sender(). Called in a slot, returns a pointer to the object that sent the signal.

  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: how to know which button emit the signal?

    You can use also QSignalMapper.

Similar Threads

  1. how to emit signal in a static function ?
    By cxl2253 in forum Qt Programming
    Replies: 32
    Last Post: 7th July 2016, 21:36
  2. emit the activated signal on a combobox
    By Equilibrium in forum Qt Programming
    Replies: 4
    Last Post: 8th November 2007, 12:33
  3. Signal defined in "a.h" can not emit in "b.cpp"
    By Shawn in forum Qt Programming
    Replies: 9
    Last Post: 21st May 2007, 16:55
  4. From extends QTreeWidgetItem emit signal?
    By patrik08 in forum Qt Programming
    Replies: 4
    Last Post: 19th May 2006, 14:54
  5. emit a signal
    By Morea in forum Qt Programming
    Replies: 2
    Last Post: 27th February 2006, 11:14

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.