开发者社区> 问答> 正文

Qt QNetworkAccessManager 运行报错 ?报错

源码编译通过,但运行时出现错误,程序直接退出。  谢谢!


我的环境是 win7 - 64bit .  错误信息如下:

Starting E:\qt_Workspace\Modules\Network\build-Http-Desktop_Qt_5_2_0_MinGW_32bit-Debug\debug\Http.exe...
Auto configuration failed
180:error:02001015:system library:fopen:Is a directory:.\crypto\bio\bss_file.c:126:fopen('g:/phpbuild/apps_install/openssl.cnf','rb')
180:error:2006D002:BIO routines:BIO_new_file:system lib:.\crypto\bio\bss_file.c:131:
180:error:0E078002:configuration file routines:DEF_LOAD:system lib:.\crypto\conf\conf_def.c:199:
QMutex: destroying locked mutex
E:\qt_Workspace\Modules\Network\build-Http-Desktop_Qt_5_2_0_MinGW_32bit-Debug\debug\Http.exe exited with code 1



源码如下:

widget.h:

#ifndef WIDGET_H
#define WIDGET_H

#include <QtNetwork>

#include "ui_form.h"

class Widget :public QWidget, public Ui::Form
{
    Q_OBJECT

public:
    Widget(QWidget *parent =0);

private slots:
    void replyFinished(QNetworkReply *reply);

private:
    QNetworkAccessManager *manager;
    Ui::Form *ui;

};


#endif // WIDGET_H



widget.cpp:

#include "widget.h"

Widget::Widget(QWidget *parent)
    :QWidget(parent)
{
    setupUi(this);

    manager = new QNetworkAccessManager(this);

    connect(manager,SIGNAL(finished(QNetworkReply*)),
            this,SLOT(replyFinished(QNetworkReply*)));
    manager->get(QNetworkRequest(QUrl("http://www.sina.com.cn")));
}

void Widget::replyFinished(QNetworkReply *reply)
{
    QTextCodec *codec = QTextCodec::codecForName("utf8");
    QString all = codec->toUnicode(reply->readAll());
    ui->textBrowser->setText(all);
    reply->deleteLater();
}



main.cpp:

#include <QApplication>
#include "widget.h"

int main(int argc,char *argv[])
{
    QApplication app(argc,argv);

    Widget widget;
    widget.show();

    return app.exec();
}






展开
收起
爱吃鱼的程序员 2020-06-20 19:06:26 760 0
1 条回答
写回答
取消 提交回答
  • https://developer.aliyun.com/profile/5yerqm5bn5yqg?spm=a2c6h.12873639.0.0.6eae304abcjaIB

    没有引用全还应该引用什么?

    2020-06-20 19:06:44
    赞同 展开评论 打赏
问答分类:
问答地址:
问答排行榜
最热
最新

相关电子书

更多
低代码开发师(初级)实战教程 立即下载
冬季实战营第三期:MySQL数据库进阶实战 立即下载
阿里巴巴DevOps 最佳实践手册 立即下载