Hello,
I don't know why slot is not working...
k.h
{
Q_OBJECT
public:
void run()
{
QTimer::singleShot(0,
this,
SLOT(doTheWork
()));
exec();
}
public slots:
void doTheWork()
{
QNetworkAccessManager accessManager;
QNetworkReply* pReply;
pReply
= accessManager.
get(QNetworkRequest
(QUrl(strUrl
)));
QObject::connect(pReply,
SIGNAL(finished
()),
&eventLoop,
SLOT(quit
()));
eventLoop.exec();
delete pReply;
qDebug() << "got img";
emit setLogo(strChannel, bData);
quit(); // not needed ?
}
private:
signals:
};
{
Q_OBJECT
public:
...
public slots:
}
class logoThread : public QThread
{
Q_OBJECT
public:
logoThread(QString param1, QString param2) { strUrl = param1; QString strChannel = param2; }
void run()
{
QTimer::singleShot(0, this, SLOT(doTheWork()));
exec();
}
public slots:
void doTheWork()
{
QNetworkAccessManager accessManager;
QNetworkReply* pReply;
QEventLoop eventLoop;
pReply = accessManager.get(QNetworkRequest(QUrl(strUrl)));
QObject::connect(pReply, SIGNAL(finished()), &eventLoop, SLOT(quit()));
eventLoop.exec();
QByteArray bData = pReply->readAll();
delete pReply;
qDebug() << "got img";
emit setLogo(strChannel, bData);
quit(); // not needed ?
}
private:
QString strUrl;
QString strChannel;
signals:
void setLogo(QString, QByteArray);
};
class k : public QObject
{
Q_OBJECT
public:
...
public slots:
void setLogoS(QString, QByteArray);
}
To copy to clipboard, switch view to plain text mode
k.cpp
void k::img()
{
....
logoThread *logoThr = new logoThread(strU, strC);
logoThr->start();
}
}
}
}
{
qDebug() << "slot";
// show img
}
void k::img()
{
....
logoThread *logoThr = new logoThread(strU, strC);
QObject::connect(logoThr, SIGNAL(setLogo(QString,QByteArray)), this, SLOT(setLogoS(QString,QByteArray)), Qt::QueuedConnection);
logoThr->start();
}
}
}
}
void k::setLogoS(QString param1, QByteArray param2)
{
qDebug() << "slot";
// show img
}
To copy to clipboard, switch view to plain text mode
Bookmarks