Results 1 to 20 of 27

Thread: Thread freezing GUI

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #10
    Join Date
    May 2007
    Posts
    90
    Qt products
    Qt4
    Platforms
    Windows
    Thanks
    40

    Default Re: Thread freezing GUI

    In the Main GUI, I create an instance of DoThis GUI and pass a pointer to each tab that is created.

    Each tab then passes that pointer to its QThread
    Qt Code:
    1. PSUEDOCODE:
    2.  
    3.  
    4. Each Tab's QThread Run Method:
    5. run{
    6. // create new objects
    7. object_1 = new object1;
    8. object_2 = new object2;
    9. //each of these signals is called once per request
    10. connect(object2,signal,object1,slot)
    11. connect(object1,signal,object2,slot)
    12. connect(DoThis,signal,object1,slot)
    13. connect(object1,signal,DoThis,slot)
    14. object2->startTCPListener();
    15. object2->startUDPListener();
    16. exec();
    17. //disconnect and delete everything
    18. }
    To copy to clipboard, switch view to plain text mode 
    Object1 then has a slot like the following:

    Qt Code:
    1. readwriteLocker.lockforWrite();
    2.  
    3. listofObjects->add(new File_Thread);
    4. uniqueID = // a new unique ID
    5. listofObjects->at(listofObjects->count()-1)->setUniqueID(uniqueID);
    6.  
    7. readwriteLocker.unlock()
    8. readwriteLocker.lockforRead()
    9.  
    10. for(int i=0; listofObjects->count()>i ; i++)
    11. {
    12. if(listofObjects->at(i)->uniqueID == uniqueID)
    13. {
    14. listofObjects->at(i)->start();
    15. }
    16. }
    17. readwriteLocker.unlock()
    To copy to clipboard, switch view to plain text mode 
    The File_Thread finished signal is connected to a similar function that deletes the object.

    Here is what the File_Thread run method looks like:
    Qt Code:
    1. run{
    2. booleanRunning = true;
    3. find_File(); //This is where everything is done, emits, io accesses, everything
    4. //This is also where the gui slows down and becomes unresponsive
    5. booleanRunning = false;
    6. }
    To copy to clipboard, switch view to plain text mode 

    Thank You all for your interest and help.

    I hope this makes the problem more clear.
    Last edited by TheGrimace; 31st May 2007 at 17:56. Reason: reformatted to look better

Similar Threads

  1. KDE/QWT doubt on debian sarge
    By hildebrand in forum KDE Forum
    Replies: 13
    Last Post: 25th April 2007, 07:13
  2. Problem closing a QMainWindow in Qt4.2
    By ian in forum Qt Programming
    Replies: 11
    Last Post: 17th October 2006, 01:49
  3. simple thread layout question
    By mhoover in forum Qt Programming
    Replies: 1
    Last Post: 12th August 2006, 12:02
  4. [QT4] QThread and printing a QList<QPixmap>
    By KShots in forum Qt Programming
    Replies: 3
    Last Post: 24th April 2006, 22:44
  5. Replies: 2
    Last Post: 6th January 2006, 22:15

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.