Results 1 to 4 of 4

Thread: Need a thread or not

  1. #1
    Join Date
    May 2006
    Posts
    57
    Thanks
    12
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Question Need a thread or not

    Hi everybody

    Well, I need some help to decide,if to use or not, threads.

    I am using QGraphicsView to draw figures, and I have a function that changes the figure, but this function is very slow. I need to be able to pause it,stop it,and restart it at any time. This function is part to the gui with information of the process and buttons to pause,stop and restart.

    As code is now; The information window is drawn until the process finishes, while the main window and the information window frezze. Maybe what is needed is a thread.

    Please somebody help me
    Thanks
    Last edited by avis_phoenix; 14th August 2008 at 22:05.

  2. #2
    Join Date
    Aug 2007
    Posts
    166
    Thanks
    16
    Thanked 14 Times in 14 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Need a thread or not

    You can make the calculations in other thread and then via signal/slots to draw it directly on the GUI.

  3. #3
    Join Date
    Jul 2008
    Location
    East Coast, USA
    Posts
    40
    Thanks
    6
    Thanked 2 Times in 1 Post
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Thumbs up Re: Need a thread or not

    Quote Originally Posted by avis_phoenix View Post
    Hi everybody

    Well, I need some help to decide,if to use or not, threads.

    I am using QGraphicsView to draw figures, and I have a function that changes the figure, but this function is very slow. I need to be able to pause it,stop it,and restart it at any time. This function is part to the gui with information of the process and buttons to pause,stop and restart.

    So what is the code; The information window is drawn until the process finishes, while the main window and the information window frezze. Maybe what is needed is a thread.

    Please somebody help me
    Thanks
    The mandelbrot example in the documentation was particularly useful for me on this topic -K

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,018 Times in 4,794 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Need a thread or not

    If your calculation is iteration based or consists of some steps then you don't need a separate thread. Signals and slots and probably QTime and QTimer inside one thread will be sufficient.

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

    avis_phoenix (19th August 2008)

Similar Threads

  1. QT + OpenGL + Thread => aaaahhhhh !
    By anthibug in forum Qt Programming
    Replies: 7
    Last Post: 26th July 2008, 13:36
  2. Thread, Timer and Socket. Comuication problem
    By ^NyAw^ in forum Qt Programming
    Replies: 6
    Last Post: 17th January 2008, 16:48
  3. KDE/QWT doubt on debian sarge
    By hildebrand in forum KDE Forum
    Replies: 13
    Last Post: 25th April 2007, 06:13
  4. Problem closing a QMainWindow in Qt4.2
    By ian in forum Qt Programming
    Replies: 11
    Last Post: 17th October 2006, 00:49
  5. [QT4] QThread and printing a QList<QPixmap>
    By KShots in forum Qt Programming
    Replies: 3
    Last Post: 24th April 2006, 21:44

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.