Multiple threads to open the same url in console application
I am new to this great QT environment and working on a demo application.
Basically I need to open urls in the console application.
- Once the url is finished loading , I need to sleep / wait that thread for a few seconds
- Meanwhile I will start another thread and open a different url and do the same kind of thing.
I guess there are two approaches to accomplish this task 1)QteventLoop 2)QThread , I chose QThread.
My code for main.cpp is
@int main(int argc, char *argv)
QApplication app(argc, argv);
//where to run the created thread ? as tr.run() works bt doesn't serve the applicaion purpose
I have created a class for thread
@class Thread: public QThread
volatile bool stopped;
std::cout<<"creating the object";
stopped = false;
std::cout << "running " << std::endl;
stopped = false;
stopped = true;
std::cout<<"stopped" << std::endl;
The code runs without error but How can I open the set of urls in the same application as in the end it returns app.exec() .
Hope I was clear to explain my problem.
Any help would be appreciated,
Can anybody help me with this ?
Why do you need a different thread? you can use QTimer.
By the way. Merely instantiating Thread object doesnt start the thread, one has to invoke start() method on it.
Also your QThread subclass implementation of the run function is missing the exec() call, so your Thread has no running eventloop. Have a look at "this link":http://qt-project.org/wiki/QThreads_general_usage .
In case the Html5ApplicationViewer instance is using any Gui class like e.g. QWebView you won't be able to run instances of this class in any other thread but the main thread. If that is what you wanted to do.