PDA

View Full Version : Call Non-static method on static method



METEOR7
2nd May 2012, 18:12
Hello Everyone
How I Call Non-static method on Static
The Static Method Used on CreateThread

How I Can Call it


Thanks

amleto
2nd May 2012, 18:13
Where Is Your Qt Question?

METEOR7
2nd May 2012, 18:25
I Use The Method on QThread

Lykurg
2nd May 2012, 20:10
I Use The Method on QThreadOk, 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.

amleto
2nd May 2012, 21:53
I Use The Method on QThread

http://qt-project.org/doc/qt-4.8/qthread-members.html

I dont see CreateThread anywhere?
:confused:

METEOR7
3rd May 2012, 11:02
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

Le_B
3rd May 2012, 13:07
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();
}

amleto
3rd May 2012, 21:26
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?