Results 1 to 20 of 52

Thread: Qt multithreading and let the second thread update the main (UI) thread

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: Qt multithreading and let the second thread update the main (UI) thread

    Quote Originally Posted by Cupidvogel View Post
    But in this case, the slot must receive an object of type QueryResult.
    Yes, I should have written updateView(const QueryResult&), but I thought it would be pretty obvious that the signal would need to transport the data as its argument.

    Quote Originally Posted by Cupidvogel View Post
    Qt greatly limits how signals and slots can use parameters
    In what way?

    Quote Originally Posted by Cupidvogel View Post
    and the one way I can see, is to use a Signal Mapper
    Why on earth would you need a signal mapper?

    Quote Originally Posted by Cupidvogel View Post
    But even with Signal Mapper, I don't know how to properly use it to say, emit a signal from one object with a QString as param, and capture and use the sent QString in a slot in another object.
    You would not use a signal mapper when you can use a trivial signal/slot connection between two objects.

    Quote Originally Posted by Cupidvogel View Post
    I browsed net heavily, I could not find a complete working example of it.
    Heavly for how many seconds?
    The first Google hit on signal/slots is the Qt documentation on that topic (which should be the primary source even without search engine help) and it does naturally have an example that transports a value through the connection.

    Quote Originally Posted by Cupidvogel View Post
    Which class here should inherit from QThread?
    The suggestion was to use moveToThread() of the worker object which does not require subclassing QThread.

    Cheers,
    _

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

    Cupidvogel (18th April 2015)

  3. #2
    Join Date
    May 2014
    Posts
    136
    Thanks
    72
    Qt products
    Qt3 Qt4 PyQt3 PyQt4
    Platforms
    MacOS X Windows

    Default Re: Qt multithreading and let the second thread update the main (UI) thread

    Can you give an example of how without using signal mapper I can transport a parameter, say, an object belonging to a custom class?

    Which object do I need to move to thread? My Query Action class?

  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: Qt multithreading and let the second thread update the main (UI) thread

    Quote Originally Posted by Cupidvogel View Post
    Can you give an example of how without using signal mapper I can transport a parameter, say, an object belonging to a custom class?
    What is it with you and the signal mapper? There is no indication of any need for a signal mapper.
    Declare a signal with the respective type as its argument type.

    Quote Originally Posted by Cupidvogel View Post
    Which object do I need to move to thread? My Query Action class?
    Well, the object that you want to run in the other thread.
    Probably the instance of your QueryFinder class.

    Cheers,
    _

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

    Cupidvogel (18th April 2015)

Similar Threads

  1. Replies: 1
    Last Post: 28th March 2012, 18:58
  2. Replies: 5
    Last Post: 22nd February 2011, 21:21
  3. Replies: 9
    Last Post: 28th November 2009, 20:31
  4. Replies: 16
    Last Post: 7th October 2009, 08:17
  5. Replies: 6
    Last Post: 29th April 2009, 18:17

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.