Results 1 to 4 of 4

Thread: QSignalMapper with one object being a thread (no visual object)

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: QSignalMapper with one object being a thread (no visual object)

    You just connect the thread's signal to the dialog's slots.

    I guess you have code like this somewhere in your dialog

    Qt Code:
    1. MyThread* thread = new MyThread(this);
    To copy to clipboard, switch view to plain text mode 
    so you just add
    Qt Code:
    1. connect(thread, SIGNAL(response(QString)), this, SLOT(showResponse(QString)));
    To copy to clipboard, switch view to plain text mode 
    and so on.

    Not sure why you would want to use a signal mapper and lose the signal arguments. Discarding the signal arguments can also be done in a normal connection.

    Cheers,
    _

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

    PeterVE (26th July 2016)

  3. #2
    Join Date
    Jul 2016
    Posts
    18
    Thanks
    3
    Qt products
    Qt5 Qt/Embedded
    Platforms
    Unix/X11

    Default Re: QSignalMapper with one object being a thread (no visual object)

    Thank you. I did exactly that and it worked. What I had used from a Qt example was working until the upgrade. I tried to find examples online using arguments and they stated to use the signal mapper. But your suggestion is what was originally intended and does work. So thank you and have a great day!

  4. #3
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: QSignalMapper with one object being a thread (no visual object)

    The signal mapper use case is if you have multiple signal sources without arguments and you want a single slot being called with arguments depending on the signal source.

    E.g. a set of buttons and having the slot called with a numerical value or string depending on which button was clicked.

    Cheers,
    _

Similar Threads

  1. TypeError: Object [object Object] has no method 'sendData'
    By TheIndependentAquarius in forum Qt Quick
    Replies: 2
    Last Post: 30th November 2013, 05:54
  2. Replies: 6
    Last Post: 25th May 2013, 22:26
  3. Replies: 1
    Last Post: 8th November 2011, 22:27
  4. QSignalMapper One single Object
    By cafu1007 in forum Qt Programming
    Replies: 7
    Last Post: 18th April 2011, 08:46
  5. Accessing ui object from thread
    By khelsys in forum Qt Programming
    Replies: 2
    Last Post: 7th October 2009, 11: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.