简体   繁体   English

请求http URL时,QT报告“QNetworkReplyHttpImplPrivate :: _ q_startOperation被多次调用”

[英]QT reports “QNetworkReplyHttpImplPrivate::_q_startOperation was called more than once” when requesting a http URL

I'm doing a very small and simple implementation of a protocol where my program will send a specific URL to a target machine and the target will reply with a JSON file. 我正在做一个非常小而简单的协议实现,我的程序会将一个特定的URL发送到目标机器,目标将使用JSON文件进行回复。

I have read many examples of how to do this in QT but still I face a log message that I don't understand and I haven't been able to figure out what the problem actually is. 我已经阅读了许多如何在QT中执行此操作的示例,但我仍然面对一条我不理解的日志消息,而且我无法弄清楚问题实际上是什么。

This is parts of my minimalistic code that sends the http request: 这是我发送http请求的简约代码的一部分:

The main class: 主要课程:

class MainWindow : public QMainWindow
{
    Q_OBJECT

public:
    explicit MainWindow(QWidget *parent = nullptr);
    ~MainWindow();

private slots:
    void on_connectToSiteButton_clicked();
    void httpFinished();
    void httpReadyRead();

signals:

private:
    Ui::MainWindow *ui;

    QByteArray *mByteArray;
    QNetworkAccessManager *mNetMan;
    QNetworkReply *reply;

};

This is the implementation of the actual sending of the network request: 这是实际发送网络请求的实现:

    void MainWindow::on_connectToSiteButton_clicked()
{

    mNetMan = new QNetworkAccessManager;
    // Send a Alarm status request
    const QUrl ALARMLIST_URL("http://192.168.1.115/JSON.HTML?FN=ALSummary");

    reply = mNetMan->get(QNetworkRequest(ALARMLIST_URL));
    connect(reply, &QNetworkReply::finished, this, &MainWindow::httpFinished);
    connect(reply, &QIODevice::readyRead, this, &MainWindow::httpReadyRead);
}

When I run the code and press the button I get following message in the Application output window: QNetworkReplyHttpImplPrivate::_q_startOperation was called more than once QUrl(" http://192.168.1.115/JSON.HTML?FN=ALSummary ") 当我运行代码并按下按钮时,我在应用程序输出窗口中收到以下消息: QNetworkReplyHttpImplPrivate :: _ q_startOperation被多次调用QUrl(“ http://192.168.1.115/JSON.HTML?FN=ALSummary ”)

When I search for a solution I find only git comments but no explanation to the cause of this. 当我搜索解决方案时,我发现只有git注释,但没有解释原因。

这似乎是(同时)已知的错误,将在Qt 5.12.2中修复: QTBUG-72463

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM