Open Web Page in QWebView/bg: Difference between revisions
Jump to navigation
Jump to search
AutoSpider (talk | contribs) (Remove non-functioning "toc" command) |
(Missing category from English version) |
||
(2 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
{{Cleanup | reason=Auto-imported from ExpressionEngine.}} | {{Cleanup | reason=Auto-imported from ExpressionEngine.}} | ||
{{LangSwitch}} | |||
[[Category: | [[Category:Developing with Qt::QtWebKit]] | ||
[[Category:Snippets::Misc]] | |||
[[Category:HowTo]] | [[Category:HowTo]] | ||
[[Category:Tutorial]] | [[Category:Tutorial]] | ||
[[Category:Bulgarian]] | |||
= Отваряне на Web страница в QWebView = | = Отваряне на Web страница в QWebView = | ||
Line 50: | Line 49: | ||
#define MAINWINDOW_H | #define MAINWINDOW_H | ||
#include < | #include <QMainWindow> | ||
#include <QWebView> | #include <QWebView> | ||
#include <QUrl> | #include <QUrl> | ||
Line 78: | Line 77: | ||
#include "mainwindow.h" | #include "mainwindow.h" | ||
#include < | #include <QCoreApplication> | ||
MainWindow::MainWindow(QWidget *parent) | MainWindow::MainWindow(QWidget *parent) | ||
Line 99: | Line 98: | ||
#include "mainwindow.h" | #include "mainwindow.h" | ||
#include < | #include <QApplication> | ||
int main(int argc, char '''argv[]) | int main(int argc, char '''argv[]) |
Latest revision as of 12:02, 28 November 2016
This article may require cleanup to meet the Qt Wiki's quality standards. Reason: Auto-imported from ExpressionEngine. Please improve this article if you can. Remove the {{cleanup}} tag and add this page to Updated pages list after it's clean. |
Отваряне на Web страница в QWebView
Даденото ръководство показва как се зарежда интернет страница чрез QUrl в QWebView. QWebView е клас, предоставен от WebKit в Qt, който се използва за показване и редакция на web документи.
- Добавете webkit в .pro файла на проекта
QT ''= webkit
- Включете нужните хедъри
#include <QWebView>
#include <QUrl>
- Създайте инстанция на QWebView
m_pWebView = new QWebView(this);
//set position and size
m_pWebView->setGeometry(0,0,200,200);
Допълинетлно може да промените стила на QWebView чрез setStyleSheet().
- Заредете web страница
m_pWebView->load(QUrl("http://www.example.com"));
Example
Предоставеният пример е създаден чрез Qt SDK 1.1 и тестван на Symbian^3 устройство.
mainwindow.h
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <QMainWindow>
#include <QWebView>
#include <QUrl>
namespace Ui {
class MainWindow;
}
class MainWindow : public QMainWindow
{
Q_OBJECT
public:
explicit MainWindow(QWidget '''parent = 0);
virtual ~MainWindow();
private:
QWebView''' m_pWebView;
};
#endif // MAINWINDOW_H
mainwindow.cpp
#include "mainwindow.h"
#include <QCoreApplication>
MainWindow::MainWindow(QWidget *parent)
: QMainWindow(parent)
{
m_pWebView = new QWebView(this);
//set position and size
m_pWebView->setGeometry(0,0,200,200);
m_pWebView->load(QUrl("http://www.example.com"));
}
MainWindow::~MainWindow()
{
}
main.cpp
#include "mainwindow.h"
#include <QApplication>
int main(int argc, char '''argv[])
{
QApplication app(argc, argv);
MainWindow mainWindow;
mainWindow.showMaximized();
return app.exec();
}
Отстраняване на проблеми
QWebView: No such file or directory
Уверете се, че сте добавили webkit в .pro файла на проекта.
QT''= webkit