Thank you for your answer.
1.The reason for using thread.
main()
{
...
for(i=0;i<max;i++)
{
// there are a lot things will be done in this circle,and it will consume much time.
}
...
}
main()
{
...
for(i=0;i<max;i++)
{
// there are a lot things will be done in this circle,and it will consume much time.
}
...
}
To copy to clipboard, switch view to plain text mode
In order to decrease the time,I want to do it with multi -threads.
for(i=0;i<max/2;i++)
//threads A does
for(i=max/2+1;i<max;i++)
//threads B does.
for(i=0;i<max/2;i++)
//threads A does
for(i=max/2+1;i<max;i++)
//threads B does.
To copy to clipboard, switch view to plain text mode
2.When I create a class like this.
{
void run()
{
}
}
class A: public QThread
{
void run()
{
QMessageBox::warning(0,"dddd","ddddd",0,0,1);
}
}
To copy to clipboard, switch view to plain text mode
run the progam,the following error will occur:
"Widgets must be created in the GUI thread.", file kernel/qwidget.cpp,
I know I do not inherit from gui widget,but if I write like this
{
void run()
{
}
}
class A: public QWidget,public QThread
{
void run()
{
QMessageBox::warning(0,"dddd","ddddd",0,0,1);
}
}
To copy to clipboard, switch view to plain text mode
error still exists.
How could I do with it?
Bookmarks