Hello Everyone
How I Call Non-static method on Static
The Static Method Used on CreateThread
How I Can Call it
Thanks
Hello Everyone
How I Call Non-static method on Static
The Static Method Used on CreateThread
How I Can Call it
Thanks
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.
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.
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.
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
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();
}
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.
Bookmarks