Embed YouTube Video in QWebView: Difference between revisions

From Qt Wiki
Jump to navigation Jump to search
No edit summary
 
No edit summary
Line 1: Line 1:
'''English''' | [[Embed YouTube Video in QWebView Spanish|Español]] | [[Embed YouTube Video in QWebView Bulgarian|Български]] | [[Embed YouTube Video in QWebView Japanese|日本語]] | [[Embed YouTube Video in QWebView Portuguese|Português]] |
'''English''' | [[Embed_YouTube_Video_in_QWebView_German|Deutsch]] | [[Embed_YouTube_Video_in_QWebView_Spanish|Español]] | [[Embed_YouTube_Video_in_QWebView_Bulgarian|Български]] | [[Embed_YouTube_Video_in_QWebView_Japanese|日本語]] | [[Embed_YouTube_Video_in_QWebView_Portuguese|Português]] |


=Embed YouTube Video in QWebView=
[[Category:snippets]]<br />[[Category:Developing_with_Qt::QtWebKit]]


Small snippet showing how to embed a YouTube video in a [http://doc.qt.io/qt-5.0/qtwebkit/qwebview.html QWebView] ''[qt.io]''. This also demonstrates Qt support for flash. <br /> First create a Qt Gui Application using Qt Creator and add a QWebView to it.
= Embed YouTube Video in QWebView =


Now add network and webkit support to your .pro file<br />
Small snippet showing how to embed a YouTube video in a &quot;QWebView&amp;quot;:http://doc.qt.io/qt-5.0/qtwebkit/qwebview.html. This also demonstrates Qt support for flash.<br />First create a Qt Gui Application using Qt Creator and add a QWebView to it.


Now add this in your mainwindow.cpp file<br />
Now add network and webkit support to your .pro file<br /><code><br />QT += core gui network webkit<br /></code>


You should be able to load the webpage with the embedded video in it.<br /> You could also embed this video only in an object tag in a local html file and just point the url to this local file.
Now add this in your mainwindow.cpp file<br /><code><br />MainWindow::MainWindow(QWidget *parent) :<br /> QMainWindow(parent),<br /> ui(new Ui::MainWindow)<br />{<br /> ui-&gt;setupUi(this);<br /> QNetworkProxyFactory::setUseSystemConfiguration (true);<br /> QWebSettings::globalSettings()<s>&gt;setAttribute(QWebSettings::PluginsEnabled, true);<br /> QWebSettings::globalSettings()</s>&gt;setAttribute(QWebSettings::AutoLoadImages, true);<br /> ui-&gt;webView-&gt;load(QUrl(&quot;http://www.youtube.com/watch?v=3aR27FLbb04&amp;quot;));<br />}<br /></code>


Detailed article on using flash with Qt can be found [http://blog.forwardbias.in/2009/12/flash-in-qgraphicsview.html here] ''[blog.forwardbias.in]''
You should be able to load the webpage with the embedded video in it.<br />You could also embed this video only in an object tag in a local html file and just point the url to this local file.


===Categories:===
Detailed article on using flash with Qt can be found &quot;here&amp;quot;:http://blog.forwardbias.in/2009/12/flash-in-qgraphicsview.html
 
* [[:Category:Developing with Qt|Developing_with_Qt]]
** [[:Category:Developing with Qt::QtWebKit|QtWebKit]]
* [[:Category:snippets|snippets]]

Revision as of 09:01, 24 February 2015

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

Embed YouTube Video in QWebView

Small snippet showing how to embed a YouTube video in a "QWebView&quot;:http://doc.qt.io/qt-5.0/qtwebkit/qwebview.html. This also demonstrates Qt support for flash.
First create a Qt Gui Application using Qt Creator and add a QWebView to it.

Now add network and webkit support to your .pro file

<br />QT += core gui network webkit<br />

Now add this in your mainwindow.cpp file

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

You should be able to load the webpage with the embedded video in it.
You could also embed this video only in an object tag in a local html file and just point the url to this local file.

Detailed article on using flash with Qt can be found "here&quot;:http://blog.forwardbias.in/2009/12/flash-in-qgraphicsview.html