Results 1 to 3 of 3

Thread: Calling Recursivly loading function in Run() method of QThread

  1. #1
    Join Date
    May 2007
    Posts
    110
    Thanks
    2
    Qt products
    Qt4
    Platforms
    MacOS X

    Default Calling Recursivly loading function in Run() method of QThread

    hi

    I m using recursivly loading directory method in Run() function of QThread.
    i m giving definiton of this method in other class and displaying in treeWidget.
    when i m calling this method using object of this class in Run() method it becomes crashed...

    void class::Run()
    {
    otherclass *obj;
    while(!bFalse)
    {
    obj->method(QString path);
    }
    }
    here while loop is better or if else.

    can u give me suggestions that why this happens..can I use Gui classes in QThread or not...

  2. #2
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Calling Recursivly loading function in Run() method of QThread

    well, to start with, in the code above 'obj' is not initialized, and that alone would make it crash.
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

  3. #3
    Join Date
    Feb 2006
    Location
    Romania
    Posts
    2,744
    Thanks
    8
    Thanked 541 Times in 521 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Calling Recursivly loading function in Run() method of QThread

    Do not modify the GUI from another thread. This must be done only by the GUI thread.
    Instead of what you do, notify the GUI thread( via signals ) and let it update the widgets.

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.