我有以下幾點:成員函數指針 - 如何做到這一點?
class NetRequest: public QObject {
Q_OBJECT
public:
NetRequest(QString postData, void(BrowserApp::*f)(QByteArray));
QString postData;
void (BrowserApp::*fn)(QByteArray);
public slots:
void requestFinished(QNetworkReply *r);
}
和CPP是:
NetRequest::NetRequest(QString postData, void(BrowserApp::*f)(QByteArray)) {
this->postData = postData;
this->fn = f;
}
void NetRequest::requestFinished(QNetworkReply *r) {
QByteArray data;
fn(data);<--- this doesn't work
}
我試圖調用requestFinished功能的「Fn」,但編譯器不會讓我 - 我是什麼請問做錯了?
感謝您對您的幫助!
正確調用語法應該是'這 - >(* FN)(數據);' –
對不起,不'這個 - >',但需要到'BrowserApp'實例有效的指針! –
「不起作用」不是錯誤消息。 –