QT程序打开网页

       1.QT程序打开网页的方法

        /* 方法一*/

    QDesktopServices::openUrl(QUrl(QString("www.baidu.com")));
    QUrl url(QString("www.baidu.com"));
    bool is_open = QDesktopServices::openUrl(url);
    /*方法二*/
    QWebView *view;
    view->page()->setLinkDelegationPolicy(QWebPage::DelegateAllLinks); //设置打开连接的方式,默认是所有二级链接都不打开
    connect(view, SIGNAL(linkClicked(QUrl)),this,SLOT(openUrlSlot(QUrl)));
    view->load(QUrl("http://www.baidu.com/"));
    view->show();


   

    2.需要包含的头文件有:   
    #include <QDesktopServices>
    #include <QUrl> 
    #include <QWebView>

       3.在.pro文件中需要添加:

    QT += webkit
    这句话

       4.以上方法的实现需要在电脑中安装OpenSSL库

          具体的安装步骤转载于:http://codeblog.vurdalakov.net/2009/11/solution-qsslsocket-cannot-call.html,http://blog.csdn.net/sgnh123456/article/details/8020683

         这里面看到了解决办法,经过测试解决问题了!   
         步骤如下:

         You need to install OpenSSL Win32 or Win64 binaries.

         你需要安装OpenSSL库;

         1、Open Win32 OpenSSL Installation Project page.

        首先打开OpenSSL Installation Project网页;


        2、Download the latest "light" Win32 or Win64 installation package, for example "Win32 OpenSSL v0.9.8l Light".

        下载安装包,我下载的是:Win64 OpenSSL v1.0.2d Lightt安装包,随着时间的推进,这个版本会不断更新的!!


        3、Install it to any location. Ignore "Microsoft Visual C++ 2008 Redistributables" warning (click OK) and select copying OpenSSL DLLs to "The OpenSSL binaries     (\bin) directory".

         安装(exe文件)到本地,我是安装到C盘下,并且在安装过程中选择将库安装到OpenSSL的安装目录(/bin)下面。


      4、Copy libeay32.dll and ssleay32.dll from the \bin folder to the same place where your QtNetwork4.dll or QtNetworkd4.dll is located.

       将libeay32.dll 和 ssleay32.dll 文件拷贝到QtSDK中的存放有QtNetwork4.dll和QtNetworkd4.dll的文件目录下。我的是

      D:\Qt\Qt5.3.2\Tools\QtCreator\bin,这个主要是看自己选择的编译器也有可能是C:\QtSDK\Desktop\Qt\4.8.0\msvc2010\bin等等!

  • 2
    点赞
  • 9
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值