I think you have things in place, only miss these
void mythread::run()
{
QNetworkAccessManager *manager= new QNetworkAccessManager();
connect(manager, SIGNAL(finished(QNetworkReply*)), this, SLOT(showData(QNetworkReply*)));
QNetworkReply
*rep
= manager
->get
(QNetworkRequest
(QUrl("http://www.google.co.in")));
exec(); //Add this
}
threadcross::~threadcross()
{
th.exit(0); //Add this, to make sure you stop and exit the thread
while(th.isRunning()); //wait for the thread to exit, and then continue, actual thread will may take longer to finish and exit, hence this wait is required to avoid application crashing while closing. There are better ways to do this, you can figure them out eventually
delete ui;
}
void mythread::run()
{
QNetworkAccessManager *manager= new QNetworkAccessManager();
connect(manager, SIGNAL(finished(QNetworkReply*)), this, SLOT(showData(QNetworkReply*)));
QNetworkReply *rep = manager->get(QNetworkRequest(QUrl("http://www.google.co.in")));
exec(); //Add this
}
threadcross::~threadcross()
{
th.exit(0); //Add this, to make sure you stop and exit the thread
while(th.isRunning()); //wait for the thread to exit, and then continue, actual thread will may take longer to finish and exit, hence this wait is required to avoid application crashing while closing. There are better ways to do this, you can figure them out eventually
delete ui;
}
To copy to clipboard, switch view to plain text mode
Bookmarks