Results 1 to 3 of 3

Thread: Creating object of other class in Run() method

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

    Default Creating object of other class in Run() method

    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

    #include "otherclass.h"
    void class::threadFunc()
    {
    ////
    }
    void class::Run()
    {
    otherclass *obj = NULL;
    obj = new otherclass;
    while(!bFalse)
    {
    obj->method(QString path);
    }
    }

    ///
    class obj;
    void otherclass::fun()
    {
    obj.threadFunc();
    }


    can u give me suggestions that why this happens..i m creating thread obj in other class and other class obj in thread class....i m confusing...it is giving error....how i use the other class function in Run() method....

  2. #2
    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: Creating object of other class in Run() method

    What error?
    Isn't this a double post?( wysota is gonna get so mad... )

    Anyways, make sure you don't create/modify GUI objects in the worker thread.
    Regards

  3. The following user says thank you to marcel for this useful post:

    santosh.kumar (15th May 2007)

  4. #3
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: Creating object of other class in Run() method

    Quote Originally Posted by marcel View Post
    Isn't this a double post?( wysota is gonna get so mad... )
    More like a pentuple thread


    Please DO NOT start new threads again and again on the same subject!
    J-P Nurmi

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.