Results 1 to 7 of 7

Thread: how can I know which object caused a specific event ?

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Oct 2009
    Posts
    483
    Thanked 97 Times in 94 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: how can I know which object caused a specific event ?

    For the record, although the sender()-based solution works, it is considered bad pratice because it breaks modularity.

    You can use the QSignalMapper class to "forward" a signal without parameters to a signal with a parameter identifying the sender. In your case this means that you lose the int parameter of the sliderMoved(int) signal, but you can recover it with QAbstractSlider::sliderPosition().

    Another solution consists in defining a distinct tiny slot for each slider that just calls a common handler with a pointer to the slider as argument.

  2. The following user says thank you to yeye_olive for this useful post:

    Hossein (21st October 2015)

Similar Threads

  1. Pass event (QWheelEvent) to a specific widget
    By stefanadelbert in forum Qt Programming
    Replies: 3
    Last Post: 5th May 2021, 03:10
  2. How to know the signal which caused a qstate transition
    By ClintEastwood in forum Qt Programming
    Replies: 6
    Last Post: 24th April 2013, 15:27
  3. Style3sheet problem, QTreeView for specific object
    By hubbobubbo in forum Qt Programming
    Replies: 2
    Last Post: 11th February 2010, 21:15
  4. Signal to specific object slot
    By bunjee in forum Qt Programming
    Replies: 2
    Last Post: 27th December 2007, 15:51
  5. Crash caused by QVariant (mis)use
    By mclark in forum Newbie
    Replies: 2
    Last Post: 31st October 2006, 15:05

Tags for this Thread

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.