How to access qwebview in QT for Windows

Source: Internet
Author: User

I have never studied networks. I have never studied networks. It took several days to get online.

If you want to learn some QT, you can play on the qt creator. What about layout and Pushbutton? After a long time, I suddenly saw qwebview. I think this may be something that can display webpages. Drag and play. Compilation fails. Why? Find it. It turns out that QT ++ = WebKit is missing in the. Pro file. Compile it. Hey, it passes. But nothing is shown. What is going on?

More than half a day later, I think of his own demo example. Load it in. Still in the connecting status, that is, the connection fails, alas. Ask someone else. PM, fat man, spoke up. Have you checked the proxy settings?

It's strange that all my proxies have been set up. Find them in the east and find them in the West. After seeing the demo running, I have a proxy set myself. Please change it. Haha, it succeeded.

All of a sudden, I understand that our network is in the domain and we should have a proxy to connect to the Internet. Although I am not familiar with Agent, I may know what is going on. I will study it later.

After a few days, continue to write the program. Refer to the demo to set the proxy method. I added some items in my mainwindow. h:

# Include <qtwebkit/qwebview>

# Include <qtnetwork/qnetworkproxy>

# Include <qtnetwork/qnetworkaccessmanager>

# Include <qsettings>

# Include <qtextcodec>

 

Class mainwindow: Public qmainwindow

{

 

...

PRIVATE:

Ui: mainwindow * UI;

Qwebview * webv;

Qnetworkproxy * proxy;

Qnetworkaccessmanager * netwkacssmng;

};

 

Code is also added in mainwindow. cpp:

Mainwindow: mainwindow (qwidget * parent)

: Qmainwindow (parent), UI (new UI: mainwindow)

{

...

Webv = qfindchild <qwebview *> (this, "webview ");

Netwkacssmng = new qnetworkaccessmanager;

 

Qnetworkproxy proxy;

 

Proxy = qnetworkproxy: httpproxy;

Proxy. sethostname (TR ("xx. xx"); // Proxy Server

Proxies. setport (8080 );

 

 

Netwkacssmng-> setproxy (proxy );

Webv-> page ()-> setnetworkaccessmanager (netwkacssmng );

 

Webv-> load (qurl ("http://www.google.com.hk /"));

Webv-> show ();

}

 

The compilation failed. It was found that QT ++ = WebKit network was missing in the. Pro file for the whole day.

Finally passed. Wait for the test. Haha ~

Successful! The Google page is displayed successfully. Although it was a small success, it was still quite happy.

I forgot. I also deleted netwkacssmng. Haha.

Maybe you shouldn't delete netwkacssmng. It's all webv pages.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.