Embed YouTube Video in QWebView/bg

From Qt Wiki
< Embed YouTube Video in QWebView
Revision as of 15:59, 16 March 2015 by AutoSpider (talk | contribs) (AutoSpider moved page Embed YouTube Video in QWebView Bulgarian to Embed YouTube Video in QWebView/bg: Localisation)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.
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.

Български | English | Deutsch | Español | 日本語 | Português |

Вграждане на YouTube видео в QWebView

Този малък отрязък от код показва как се вгражда YouTube видео в QWebView. Също така демонстрира Qt поддръжка на flash. Първо създайте Qt Gui Application чрез Qt Creator и добавете QWebView към него.

След това добавете поддръжка на network и webkit във Вашия .pro файл:

QT += core gui network webkit

В your mainwindow.cpp добавете

MainWindow::MainWindow(QWidget *parent) :
 QMainWindow(parent),
 ui(new Ui::MainWindow)
{
 ui->setupUi(this);
 QNetworkProxyFactory::setUseSystemConfiguration (true);
 QWebSettings::globalSettings()->setAttribute(QWebSettings::PluginsEnabled, true);
 QWebSettings::globalSettings()->setAttribute(QWebSettings::AutoLoadImages, true);
 ui->webView->load(QUrl("http://www.youtube.com/watch?v=3aR27FLbb04"));
}

Трябва да можете да заредите web страницата с вграденото видео в нея. Също така можете да вградите самото видео в локална HTML страница и да посочите пътя до този файл.

Повече детайли как се използва flash в Qt могат да бъдат намерени тук