PDA

View Full Version : How to open several windows (QWidgets) at once?



Timus83
23rd October 2010, 17:29
Hello!

I'm trying to create web interface testing program which should open two urls in two (or more) webkit windows simultaneously.

I already did the code for the test automation which perfectly works in single way mode:

1) User pushes 'Go' button and webkit (QWidget) window opens

2) TestBot class object performs tests

3) Closes

Now my question: After clicking on the button 'Go', how do I open two (or three or more) webkit (QWidget) windows, I mean, how do I launch several TestBots simultaneously so they do all the work parallel?

I understood, that I need to look at multithreads, I came up I need to inherit QThread into my TestBot class definition as 'class TestBot : public QThread', but is this right solution and do I do it right? What's to do next?

Can't I just write code as:


QThread process1;
QThread process2;
process1->start();
//some code here
process1->quit();

process2->start();
//some code here
process2->quit();
to make everything work parallel?

I'm a newbie in Winapp world, I came from Web programming. Hope for your help!

high_flyer
25th October 2010, 09:27
'class TestBot : public QThread', but is this right solution and do I do it right? What's to do next?
Well, putting your TestBot in to a thread sounds the right way to go, but we can't tell if you are doing it right since you didn't post any code.
However, just subclassing is not enough.
You have to adjust your code to work as worker thread.
Based on the way you are asking, its sounds you don't really know what threaded programming really is.
I recommend you first read some general principals of threaded programming, and then the QThread docs.