Results 1 to 8 of 8

Thread: Call Non-static method on static method

  1. #1
    Join Date
    Oct 2011
    Posts
    36
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Call Non-static method on static method

    Hello Everyone
    How I Call Non-static method on Static
    The Static Method Used on CreateThread

    How I Can Call it


    Thanks

  2. #2
    Join Date
    Sep 2011
    Posts
    1,241
    Thanks
    3
    Thanked 127 Times in 126 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Call Non-static method on static method

    Where Is Your Qt Question?
    If you have a problem, CUT and PASTE your code. Do not retype or simplify it. Give a COMPLETE and COMPILABLE example of your problem. Otherwise we are all guessing the problem from a fabrication where relevant details are often missing.

  3. #3
    Join Date
    Oct 2011
    Posts
    36
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Re: Call Non-static method on static method

    I Use The Method on QThread

  4. #4
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: Call Non-static method on static method

    Quote Originally Posted by METEOR7 View Post
    I Use The Method on QThread
    Ok, that is the same relation as when I am sitting on the toilet wearing a Qt-t-shirt and wonder where my toilet paper is gone and ask here "where can I find new toilet paper?". But anyway:

    Create an object and call the function.

    For a more precise answer we need some more informations about the function, what they do and what you expect what they should do.

  5. #5
    Join Date
    Sep 2011
    Posts
    1,241
    Thanks
    3
    Thanked 127 Times in 126 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Call Non-static method on static method

    Quote Originally Posted by METEOR7 View Post
    I Use The Method on QThread
    http://qt-project.org/doc/qt-4.8/qthread-members.html

    I dont see CreateThread anywhere?
    If you have a problem, CUT and PASTE your code. Do not retype or simplify it. Give a COMPLETE and COMPILABLE example of your problem. Otherwise we are all guessing the problem from a fabrication where relevant details are often missing.

  6. #6
    Join Date
    Oct 2011
    Posts
    36
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Re: Call Non-static method on static method

    this is my code

    DWORD Worker(PSCANNER_THREAD_CONTEXT Context)
    {
    while (TRUE)
    {
    // I Want Call CTF Here For Emit Value
    // For Example CTF("ABC")
    }
    }

    void myclass::run()
    {
    DWORD requestCount = SCANNER_DEFAULT_REQUEST_COUNT;
    DWORD threadCount = SCANNER_DEFAULT_THREAD_COUNT;
    HANDLE threads[SCANNER_MAX_THREAD_COUNT];
    SCANNER_THREAD_CONTEXT context;
    DWORD threadId;DWORD i, j;HRESULT hr;


    for (i = 0; i < threadCount; i++)
    {
    threads[i] = CreateThread(NULL,0,
    (LPTHREAD_START_ROUTINE)Worker,
    &context,0,&threadId);
    if (threads[i] == NULL){return;}

    }
    }

    void myclass::CTF(QString f)
    {
    emit SValue(f);
    }


    Sorry I'm not explain

  7. #7
    Join Date
    Nov 2010
    Posts
    82
    Thanked 9 Times in 9 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Call Non-static method on static method

    all your threads run the worker function so why don't you subclass QThread and put the code from the worker function into the run function of your customThread
    then in your loop do something like:
    for (i = 0; i < threadCount; i++)
    {
    customThread* thread = new customThread(this);
    threadList.append(thread);
    thread->start();
    }

  8. #8
    Join Date
    Sep 2011
    Posts
    1,241
    Thanks
    3
    Thanked 127 Times in 126 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Call Non-static method on static method

    it looks absurd.

    Why are you using win api for threads in a Qt class when Qt provides cross platform support for threads?

    CreateThread is not portable, and is more clunky and difficult to use than QThread. Why aren't you using QThread?
    If you have a problem, CUT and PASTE your code. Do not retype or simplify it. Give a COMPLETE and COMPILABLE example of your problem. Otherwise we are all guessing the problem from a fabrication where relevant details are often missing.

Similar Threads

  1. C++ method call
    By ^NyAw^ in forum General Programming
    Replies: 4
    Last Post: 19th November 2011, 12:19
  2. How to emit signal from static method?
    By kusumat in forum Qt Programming
    Replies: 3
    Last Post: 20th July 2011, 09:17
  3. Replies: 6
    Last Post: 15th April 2010, 20:02
  4. Why can't I call base public method?
    By lni in forum Qt Programming
    Replies: 3
    Last Post: 13th April 2009, 20:37
  5. Static field and public method
    By probine in forum General Programming
    Replies: 1
    Last Post: 5th March 2006, 11:02

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.