QT multi-tag browser (1) and qt tag Browser
I recently used QT to write a simple browser. The original version is 5.7. Instead of QWebView, I used QAxWidget to load ie. The advantage is that the webpage can be opened quickly, but when you click a link in the webpage, windows IE browser will be automatically called, the level is limited, and you do not know how to open it in your own program, the search is fruitless, you have to give up using QAxWidget (please kindly advise !!!), Reduce QT to 5.6 and use QWebView.
(1) Draw the QT Interface
Add 6 qtoolbuttons and a qlineedits, and search for .png in the qtinstallation directory;
Add a QTabWidget and a QWebView. The effect is as follows:
(2) Add a slot function to open a webpage and link the carriage return signal and slot function in the address bar.
Void LXBrowser: goWeb () {QString url = ui. addressLineEdit-> text (); url = "http: //" + url; // you must add http: // to open the webpage... Ui. webView-> load (url);} to be improved );}
(3) connect the linkClicked (const QUrl &) signal and slot functions in QWebView to open a webpage on a new page.
connect(ui.webView, SIGNAL(linkClicked(const QUrl &)), this, SLOT(clickLink(const QUrl &)));
void LXBrowser::clickLink(const QUrl &linkUrl){ QWebView* newWebView = new QWebView(); newWebView->load(linkUrl); int index = ui.tabWidget->addTab(newWebView, linkUrl.fileName()); ui.tabWidget->setCurrentIndex(index); ui.addressLineEdit->setText(linkUrl.toString());}
Effect:
A super simple browser is complete, hahaha
Problems:
1. The forward, backward, stop, add to favorites, and history functions have not yet been implemented;
2. title of the new tag;
3. Slow webpage access, especially for websites with iQiYi, Youku, and many other videos or images;
4. You need to add a status bar to display the percentage of the current webpage loaded