Results 1 to 8 of 8

Thread: MultiThreading in Qt

  1. #1
    Join Date
    Aug 2006
    Location
    banglore
    Posts
    21
    Thanks
    1
    Qt products
    Qt3 Qt4
    Platforms
    Windows

    Default MultiThreading in Qt

    Hi All,


    Any body help me to implement multi threading .. I am not able to find any examples..

    I am working on Automated Futures Trading System, i have a functions which reads a data from a particular file and send to my GUI. Consider I have data in many files, all files need to read parallely and send to GUI same time.

    Pls give me suggestions..


    Regards,
    Mani

  2. #2
    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: MultiThreading in Qt

    See %QTDIR%/examples/threads.

  3. #3
    Join Date
    Aug 2006
    Location
    banglore
    Posts
    21
    Thanks
    1
    Qt products
    Qt3 Qt4
    Platforms
    Windows

    Default Re: MultiThreading in Qt

    In the examples for each thread a class has been derived..

    But I need to run multiple threads at a time (more than 10) in a single class, hence I cant create class for each thread.. But I going to perform a single function which has one parameter inside those threads.. so i need to run that function paralelly..

    Without creating instances for that class where I have my functions, Can I implement multi threading..?

  4. #4
    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: MultiThreading in Qt

    Quote Originally Posted by manivannan_1984 View Post
    In the examples for each thread a class has been derived..
    What prohibits you creating several instances of such class?

  5. #5
    Join Date
    Mar 2006
    Location
    Mountain View, California
    Posts
    489
    Thanks
    3
    Thanked 74 Times in 54 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: MultiThreading in Qt

    Quote Originally Posted by manivannan_1984 View Post
    In the examples for each thread a class has been derived..
    If you have multiple threads and they all use the same run() function, (otherwise known as the thread routine), then you only need to create one QThread derived class.

  6. #6
    Join Date
    Aug 2006
    Location
    Zürich, Switzerland
    Posts
    23
    Thanks
    1
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: MultiThreading in Qt

    You could use the Posix threads library directly which is available for Unix, Linux and Win systems. Have a look at this tutorial:

    http://www.llnl.gov/computing/tutorials/pthreads/

    But if ever possible you should derive from QThread and create an instance for every thread you need - for sure makes your life much easier.
    Ernst

  7. #7
    Join Date
    Aug 2006
    Location
    banglore
    Posts
    21
    Thanks
    1
    Qt products
    Qt3 Qt4
    Platforms
    Windows

    Default Re: MultiThreading in Qt

    Thanks for all your suggestions..

    Actually I have a requirement to do this with out creating instances.. But i think that is only the easier way...

    Thanks,
    Mani

  8. #8
    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: MultiThreading in Qt

    Quote Originally Posted by manivannan_1984 View Post
    Actually I have a requirement to do this with out creating instances..
    Excuse me, but what do you intend to use instead? If you want to do it the object-oriented way, you have to use instances (i.e. objects).

Similar Threads

  1. MultiThreading n Qhttp
    By Shambhavi in forum Qt Programming
    Replies: 1
    Last Post: 18th January 2006, 13:36

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.