<?xml version="1.0" encoding="utf-8"?><?xml-stylesheet title="XSL formatting" type="text/xsl" href="http://doc.qtfr.org/feed/rss2/xslt" ?><rss version="2.0"
  xmlns:dc="http://purl.org/dc/elements/1.1/"
  xmlns:wfw="http://wellformedweb.org/CommentAPI/"
  xmlns:content="http://purl.org/rss/1.0/modules/content/">
<channel>
  <title>Documentation Qtfr - version_Qt3</title>
  <link>http://doc.qtfr.org/</link>
  <description>La documentation francophone sur Qt</description>
  <language>fr</language>
  <pubDate>Thu, 06 Nov 2008 23:03:54 +0100</pubDate>
  <copyright></copyright>
  <docs>http://blogs.law.harvard.edu/tech/rss</docs>
  <generator>Dotclear</generator>
  
    
  <item>
    <title>Un conteneur pour MPlayer (utilisation de QProcess)</title>
    <link>http://doc.qtfr.org/post/2007/03/21/Un-conteneur-pour-MPlayer-utilisation-de-QProcess</link>
    <guid isPermaLink="false">urn:md5:afa61892107e63fea382cac105f90974</guid>
    <pubDate>Mon, 02 Apr 2007 09:01:00 +0200</pubDate>
    <dc:creator>IrmatDen</dc:creator>
        <category>Tutoriels</category>
        <category>class_QProcess</category><category>class_QWidget</category><category>intégration</category><category>MPlayer</category><category>version_PyQt4</category><category>version_Qt3</category><category>version_Qt4</category>    
    <description>&lt;ul&gt;
&lt;li&gt;Comment visualiser une vidéo dans Qt&amp;nbsp;?&lt;/li&gt;
&lt;li&gt;Comment intégrer MPlayer et Qt&amp;nbsp;?&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Qt, dans son souci de framework généraliste, n'implémente pas toujours tout ce dont on peut avoir besoin, surtout lorsque cela n'est pas d'usage courant. Les vidéos font partie de ce qui n'était pas couvert par Qt (maintenant supporté depuis la 4.4 par le biais de Phonon). Cependant, un grand nombre de librairies et autres backends existent.
Nous allons voir comment utiliser l'un d'entre eux: &lt;a href=&quot;http://www.mplayerhq.hu/design7/news.html&quot;&gt;MPlayer&lt;/a&gt;.&lt;/p&gt;


&lt;p&gt;&lt;strong&gt;Version concernée&lt;/strong&gt;&amp;nbsp;: Toutes versions (exemple fait avec C++/Qt4 et une version pyQt disponible)&lt;br /&gt;
&lt;strong&gt;Auteur&lt;/strong&gt;&amp;nbsp;: Denys Bulant (&lt;a href=&quot;http://qtfr.org/forum/profile.php?id=291&quot;&gt;IrmatDen&lt;/a&gt;), &lt;a href=&quot;http://forum.qtfr.org/profile.php?id=2344&quot;&gt;alteo_gange&lt;/a&gt; et &lt;a href=&quot;http://forum.qtfr.org/profile.php?id=4253&quot;&gt;egaudrain&lt;/a&gt; pour les versions pyQt&lt;br /&gt;
&lt;strong&gt;Résumé&lt;/strong&gt;&amp;nbsp;: utiliser MPlayer conjointement à Qt pour afficher une vidéo&lt;br /&gt;
&lt;strong&gt;Fil de discussion&lt;/strong&gt;&amp;nbsp;: &lt;a href=&quot;http://forum.qtfr.org/viewtopic.php?pid=14373&quot;&gt;Forum&lt;/a&gt;&lt;/p&gt;    &lt;h3&gt;Généralité sur MPlayer en tant que backend...&lt;/h3&gt;

&lt;p&gt;La particularité de MPlayer est de ne pas s'intégrer par le biais d'une api, mais par un process externe. Les applications désirant l'utiliser en tant que tel, doivent communiquer avec lui par le biais de son flux d'entrée. Les flux de sorties (standard/erreur) peuvent bien sûr être analysés pour récupérer diverses infos sur la vidéo ainsi que les réponses à des requêtes pouvant être formulées par votre application.&lt;/p&gt;


&lt;p&gt;Voici ce dont vous aurez besoin&amp;nbsp;:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;http://www.mplayerhq.hu/design7/dload.html&quot;&gt;MPlayer&lt;/a&gt; installé, et fonctionnel,&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://www.mplayerhq.hu/DOCS/man/en/mplayer.1.html&quot;&gt;La page des options de MPlayer&lt;/a&gt;,&lt;/li&gt;
&lt;li&gt;Et &lt;a href=&quot;http://www.mplayerhq.hu/DOCS/tech/slave.txt&quot;&gt;la liste des options en slave mode&lt;/a&gt; pour mplayer (c'est toutes les manip qui vous sont permises, donc considérez ce fichier comme votre référence ;)).&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Pour utiliser MPlayer comme backend, il y a 2 arguments à lui passer &lt;strong&gt;impérativement&lt;/strong&gt;:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;l'id du widget à utiliser pour le rendu par le biais de &quot;-wid&quot;&lt;/li&gt;
&lt;li&gt;&quot;-slave&quot; qui permet de le mettre en mode esclave, d'où le nom  ;-)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Exemple de code lançant MPlayer comme backend:&lt;/p&gt;
&lt;pre class=&quot;cpp&quot;&gt;QStringList args;
&lt;span style=&quot;color: #ff0000;&quot;&gt;// On demande à utiliser mplayer comme backend&lt;/span&gt;
args &amp;lt;&amp;lt; &lt;span style=&quot;color: #666666;&quot;&gt;&amp;quot;-slave&amp;quot;&lt;/span&gt;;
&lt;span style=&quot;color: #339900;&quot;&gt;#ifdef Q_WS_WIN&lt;/span&gt;
&lt;span style=&quot;color: #ff0000;&quot;&gt;// reinterpret_cast&amp;lt;unsigned int&amp;gt; obligatoire, HWND ne se laissant pas convertir gentiment ;)&lt;/span&gt;
args &amp;lt;&amp;lt; &lt;span style=&quot;color: #666666;&quot;&gt;&amp;quot;-wid&amp;quot;&lt;/span&gt; &amp;lt;&amp;lt; QString::&lt;span style=&quot;color: #00eeff;&quot;&gt;number&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;reinterpret_cast&amp;lt;unsigned int&amp;gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;renderTarget-&amp;gt;winId&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;;
&lt;span style=&quot;color: #339900;&quot;&gt;#else&lt;/span&gt;
&lt;span style=&quot;color: #ff0000;&quot;&gt;// Sur linux, pas de manip pour Wid :)&lt;/span&gt;
args &amp;lt;&amp;lt; &lt;span style=&quot;color: #666666;&quot;&gt;&amp;quot;-wid&amp;quot;&lt;/span&gt; &amp;lt;&amp;lt; QString::&lt;span style=&quot;color: #00eeff;&quot;&gt;number&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;renderTarget-&amp;gt;winId&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;;
&lt;span style=&quot;color: #339900;&quot;&gt;#endif&lt;/span&gt;&lt;/pre&gt;


&lt;p&gt;A savoir aussi que sur Windows, je n'ai trouvé que directx comme driver de sortie :/ Cela ne concerne pas les autres OS; lors de mon test sur Linux, je n'ai eu aucun driver à spécifier et cela marche nickel.&lt;/p&gt;


&lt;p&gt;Et apparemment les seuls drivers compatibles pour un embarquement de MPlayer sous Linux sont xv, x11 et gl. Et sous Linux, il faut faire attention à avoir un widget de taille raisonnable pour contenir la vidéo. En effet, contrairement à Windows, un resize à la volée n'est pas possible :/&lt;/p&gt;


&lt;p&gt;Ensuite, le mode esclave permet donc de commander MPlayer pour:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;obtenir des infos (ex: get_video_resolution/get_time_length/...)&lt;/li&gt;
&lt;li&gt;lui donner un ordre (ex: play/pause/quit/...)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Tout ce qui lui est transmis, doit être terminé par un retour chariot. Si vous demandiez une information, elle sera renvoyée sur la sortie standard, avec un début de ligne propre à chaque commande (ex: get_video_resolution renverra &lt;code&gt;ANS_VIDEO_RESOLUTION='resX x resY'&lt;/code&gt;)&lt;/p&gt;


&lt;h3&gt;Exemple complet&lt;/h3&gt;

&lt;p&gt;&lt;img src=&quot;http://doc.qtfr.org/public/2006/previewqtmplayerui.png&quot; alt=&quot;Illustration MPlayer/Qt&quot; style=&quot;display:block; margin:0 auto;&quot; /&gt;&lt;/p&gt;


&lt;p&gt;Voici un programme proposant les fonctionnalités suivantes:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;lecture d'une vidéo&lt;/li&gt;
&lt;li&gt;arrêt&lt;/li&gt;
&lt;li&gt;avancer/reculer en déplaçant le slider&lt;/li&gt;
&lt;li&gt;affiche le log de toutes ce qui sort sur les flux stdout et stderr de mplayer&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Vous le trouverez en annexe de ce tuto&amp;nbsp;; seuls les points essentiels sont repris ici par souci de clarté.
Pour vos tests, &lt;strong&gt;pensez à changer&lt;/strong&gt; les valeurs de &lt;code&gt;mPlayerPath&lt;/code&gt; et &lt;code&gt;movieFile&lt;/code&gt;, en haut du fichier.&lt;/p&gt;


&lt;p&gt;Ce n'est pas un frontend complet, mais cela vous permettra de voir fonctionner Qt 4 avec MPlayer en utilisant &lt;code&gt;QProcess&lt;/code&gt;  :)&lt;/p&gt;


&lt;p&gt;Comme dit dans l'introduction, une version pyQt a été réalisée par &lt;a href=&quot;http://forum.qtfr.org/profile.php?id=2344&quot;&gt;alteo_gange&lt;/a&gt;. Elle est disponible sur le &lt;a href=&quot;http://forum.qtfr.org/viewtopic.php?pid=31501#p31501&quot;&gt;forum&lt;/a&gt;. A noter qu'une version multi-plateforme a été postée par &lt;a href=&quot;http://forum.qtfr.org/profile.php?id=4253&quot;&gt;egaudrain&lt;/a&gt;; le code est dispo à ce &lt;a href=&quot;http://forum.qtfr.org/viewtopic.php?pid=37823#p37823&quot;&gt;post&lt;/a&gt;.&lt;/p&gt;
&lt;pre class=&quot;cpp&quot;&gt;&lt;span style=&quot;color: #0000ff;&quot;&gt;class&lt;/span&gt; PlayerWidget: &lt;span style=&quot;color: #0000ff;&quot;&gt;public&lt;/span&gt; QWidget
&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#123;&lt;/span&gt;
    Q_OBJECT
&amp;nbsp;
&lt;span style=&quot;color: #0000ff;&quot;&gt;public&lt;/span&gt;:
    PlayerWidget&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;QWidget *parent =&lt;span style=&quot;color: #0000dd;&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;
        :QWidget&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;parent&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;, isPlaying&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0000ff;&quot;&gt;false&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;
    &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#123;&lt;/span&gt;
        &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#91;&lt;/span&gt;...&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#93;&lt;/span&gt;
        renderTarget = &lt;span style=&quot;color: #0000dd;&quot;&gt;new&lt;/span&gt; QWidget;
        renderTarget-&amp;gt;setSizePolicy&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;QSizePolicy&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;QSizePolicy::&lt;span style=&quot;color: #00eeff;&quot;&gt;Fixed&lt;/span&gt;, QSizePolicy::&lt;span style=&quot;color: #00eeff;&quot;&gt;Fixed&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;;
        renderTarget-&amp;gt;setAttribute&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;Qt::&lt;span style=&quot;color: #00eeff;&quot;&gt;WA_PaintOnScreen&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;;
        renderTarget-&amp;gt;setMinimumSize&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0000dd;&quot;&gt;320&lt;/span&gt;, &lt;span style=&quot;color: #0000dd;&quot;&gt;240&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;;
        &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#91;&lt;/span&gt;...&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#93;&lt;/span&gt;
&amp;nbsp;
        mplayerProcess = &lt;span style=&quot;color: #0000dd;&quot;&gt;new&lt;/span&gt; QProcess&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0000dd;&quot;&gt;this&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;;
&amp;nbsp;
        &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#91;&lt;/span&gt;...&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#93;&lt;/span&gt;
        connect&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;mplayerProcess, &lt;span style=&quot;color: #0000ff;&quot;&gt;SIGNAL&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;readyReadStandardOutput&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;,
            &lt;span style=&quot;color: #0000dd;&quot;&gt;this&lt;/span&gt;, SLOT&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;catchOutput&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;;
        connect&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;mplayerProcess, &lt;span style=&quot;color: #0000ff;&quot;&gt;SIGNAL&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;finished&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0000ff;&quot;&gt;int&lt;/span&gt;, QProcess::&lt;span style=&quot;color: #00eeff;&quot;&gt;ExitStatus&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;,
            &lt;span style=&quot;color: #0000dd;&quot;&gt;this&lt;/span&gt;, SLOT&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;mplayerEnded&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0000ff;&quot;&gt;int&lt;/span&gt;, QProcess::&lt;span style=&quot;color: #00eeff;&quot;&gt;ExitStatus&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;;
        &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#91;&lt;/span&gt;...&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#93;&lt;/span&gt;
    &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#125;&lt;/span&gt;
&amp;nbsp;
&lt;span style=&quot;color: #0000ff;&quot;&gt;protected&lt;/span&gt;:
    &lt;span style=&quot;color: #0000ff;&quot;&gt;virtual&lt;/span&gt; &lt;span style=&quot;color: #0000ff;&quot;&gt;void&lt;/span&gt; closeEvent&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;QCloseEvent *e&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;
    &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#123;&lt;/span&gt;
        &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#91;&lt;/span&gt;...&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#93;&lt;/span&gt;
    &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#125;&lt;/span&gt;
&amp;nbsp;
    &lt;span style=&quot;color: #0000ff;&quot;&gt;private&lt;/span&gt;:
    &lt;span style=&quot;color: #0000ff;&quot;&gt;bool&lt;/span&gt; startMPlayer&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;
    &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#123;&lt;/span&gt;
        &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#91;&lt;/span&gt;...&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#93;&lt;/span&gt;
        QStringList args;
        &lt;span style=&quot;color: #ff0000;&quot;&gt;// On demande à utiliser mplayer comme backend&lt;/span&gt;
        args &amp;lt;&amp;lt; &lt;span style=&quot;color: #666666;&quot;&gt;&amp;quot;-slave&amp;quot;&lt;/span&gt;;
        &lt;span style=&quot;color: #ff0000;&quot;&gt;// Et on veut ne pas avoir trop de chose à parser  :) &lt;/span&gt;
        args &amp;lt;&amp;lt; &lt;span style=&quot;color: #666666;&quot;&gt;&amp;quot;-quiet&amp;quot;&lt;/span&gt;;
&amp;nbsp;
&lt;span style=&quot;color: #339900;&quot;&gt;#ifdef Q_WS_WIN&lt;/span&gt;
        &lt;span style=&quot;color: #ff0000;&quot;&gt;// reinterpret_cast&amp;lt;qlonglong&amp;gt; obligatoire, winId() ne se laissant pas convertir gentiment ;)&lt;/span&gt;
        args &amp;lt;&amp;lt; &lt;span style=&quot;color: #666666;&quot;&gt;&amp;quot;-wid&amp;quot;&lt;/span&gt; &amp;lt;&amp;lt; QString::&lt;span style=&quot;color: #00eeff;&quot;&gt;number&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;reinterpret_cast&amp;lt;qlonglong&amp;gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;renderTarget-&amp;gt;winId&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;;
        args &amp;lt;&amp;lt; &lt;span style=&quot;color: #666666;&quot;&gt;&amp;quot;-vo&amp;quot;&lt;/span&gt; &amp;lt;&amp;lt; &lt;span style=&quot;color: #666666;&quot;&gt;&amp;quot;directx:noaccel&amp;quot;&lt;/span&gt;;
&lt;span style=&quot;color: #339900;&quot;&gt;#else&lt;/span&gt;
        &lt;span style=&quot;color: #ff0000;&quot;&gt;// Sur linux, aucun driver n'a été nécessaire et pas de manip pour Wid :)&lt;/span&gt;
        args &amp;lt;&amp;lt; &lt;span style=&quot;color: #666666;&quot;&gt;&amp;quot;-wid&amp;quot;&lt;/span&gt; &amp;lt;&amp;lt; QString::&lt;span style=&quot;color: #00eeff;&quot;&gt;number&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;renderTarget-&amp;gt;winId&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;;
        log-&amp;gt;append&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #666666;&quot;&gt;&amp;quot;Video output driver may not be necessary for your platform. &lt;span style=&quot;color: #666666; font-weight: bold;&quot;&gt;\&lt;/span&gt;
                    Check: http://www.mplayerhq.hu/DOCS/man/en/mplayer.1.html &lt;span style=&quot;color: #666666; font-weight: bold;&quot;&gt;\&lt;/span&gt;
                    at the VIDEO OUTPUT DRIVERS section.&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;;
&lt;span style=&quot;color: #339900;&quot;&gt;#endif&lt;/span&gt;
&amp;nbsp;
        args &amp;lt;&amp;lt; movieFile;
        qDebug&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;args.&lt;span style=&quot;color: #00eeff;&quot;&gt;join&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #666666;&quot;&gt;&amp;quot; &amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;.&lt;span style=&quot;color: #00eeff;&quot;&gt;toUtf8&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;;
&amp;nbsp;
        &lt;span style=&quot;color: #ff0000;&quot;&gt;// On parse la stdout et stderr au même endroit, donc on demande à &amp;quot;fusionnner&amp;quot; les 2 flux&lt;/span&gt;
        mplayerProcess-&amp;gt;setProcessChannelMode&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;QProcess::&lt;span style=&quot;color: #00eeff;&quot;&gt;MergedChannels&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;;
        mplayerProcess-&amp;gt;start&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;mplayerPath, args&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;;
        &lt;span style=&quot;color: #0000ff;&quot;&gt;if&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;!mplayerProcess-&amp;gt;waitForStarted&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0000dd;&quot;&gt;3000&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;
        &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#123;&lt;/span&gt;
            qDebug&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #666666;&quot;&gt;&amp;quot;allez, cherche le bug :o&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;;
            &lt;span style=&quot;color: #0000ff;&quot;&gt;return&lt;/span&gt; &lt;span style=&quot;color: #0000ff;&quot;&gt;false&lt;/span&gt;;
        &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#125;&lt;/span&gt;
&amp;nbsp;
        &lt;span style=&quot;color: #ff0000;&quot;&gt;// On récupère les infos de base&lt;/span&gt;
        mplayerProcess-&amp;gt;write&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #666666;&quot;&gt;&amp;quot;get_video_resolution&lt;span style=&quot;color: #666666; font-weight: bold;&quot;&gt;\n&lt;/span&gt;&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;;
        mplayerProcess-&amp;gt;write&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #666666;&quot;&gt;&amp;quot;get_time_length&lt;span style=&quot;color: #666666; font-weight: bold;&quot;&gt;\n&lt;/span&gt;&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;;
        &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#91;&lt;/span&gt;...&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#93;&lt;/span&gt;
    &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#125;&lt;/span&gt;
&amp;nbsp;
    &lt;span style=&quot;color: #0000ff;&quot;&gt;bool&lt;/span&gt; stopMPlayer&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;
    &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#123;&lt;/span&gt;
        &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#91;&lt;/span&gt;...&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#93;&lt;/span&gt;
        mplayerProcess-&amp;gt;write&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #666666;&quot;&gt;&amp;quot;quit&lt;span style=&quot;color: #666666; font-weight: bold;&quot;&gt;\n&lt;/span&gt;&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;;
        &lt;span style=&quot;color: #0000ff;&quot;&gt;if&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;!mplayerProcess-&amp;gt;waitForFinished&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0000dd;&quot;&gt;3000&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;
        &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#123;&lt;/span&gt;
            qDebug&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #666666;&quot;&gt;&amp;quot;ZOMG, ça plante :(&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;;
            &lt;span style=&quot;color: #0000ff;&quot;&gt;return&lt;/span&gt; &lt;span style=&quot;color: #0000ff;&quot;&gt;false&lt;/span&gt;;
        &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#125;&lt;/span&gt;
&amp;nbsp;
        &lt;span style=&quot;color: #0000ff;&quot;&gt;return&lt;/span&gt; &lt;span style=&quot;color: #0000ff;&quot;&gt;true&lt;/span&gt;;
    &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#125;&lt;/span&gt;
&amp;nbsp;
&lt;span style=&quot;color: #0000ff;&quot;&gt;private&lt;/span&gt; slots:
    &lt;span style=&quot;color: #0000ff;&quot;&gt;void&lt;/span&gt; catchOutput&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;
    &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#123;&lt;/span&gt;
        &lt;span style=&quot;color: #0000ff;&quot;&gt;while&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;mplayerProcess-&amp;gt;canReadLine&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;
        &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#123;&lt;/span&gt;
            QByteArray buffer&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;mplayerProcess-&amp;gt;readLine&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;;
            log-&amp;gt;append&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;QString&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;buffer&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;;
&amp;nbsp;
            &lt;span style=&quot;color: #ff0000;&quot;&gt;// On vérifie si on a eu des réponses&lt;/span&gt;
            &lt;span style=&quot;color: #ff0000;&quot;&gt;// réponse à get_video_resolution : ANS_VIDEO_RESOLUTION='176 x 144'&lt;/span&gt;
            &lt;span style=&quot;color: #0000ff;&quot;&gt;if&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;buffer.&lt;span style=&quot;color: #00eeff;&quot;&gt;startsWith&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #666666;&quot;&gt;&amp;quot;ANS_VIDEO_RESOLUTION&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;
            &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#123;&lt;/span&gt;
                buffer.&lt;span style=&quot;color: #0000dd;&quot;&gt;remove&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0000dd;&quot;&gt;0&lt;/span&gt;, &lt;span style=&quot;color: #0000dd;&quot;&gt;21&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;;
                buffer.&lt;span style=&quot;color: #00eeff;&quot;&gt;replace&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;QByteArray&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #666666;&quot;&gt;&amp;quot;'&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;, QByteArray&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #666666;&quot;&gt;&amp;quot;&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;;
                buffer.&lt;span style=&quot;color: #00eeff;&quot;&gt;replace&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;QByteArray&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #666666;&quot;&gt;&amp;quot; &amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;, QByteArray&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #666666;&quot;&gt;&amp;quot;&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;;
                buffer.&lt;span style=&quot;color: #00eeff;&quot;&gt;replace&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;QByteArray&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #666666;&quot;&gt;&amp;quot;&lt;span style=&quot;color: #666666; font-weight: bold;&quot;&gt;\n&lt;/span&gt;&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;, QByteArray&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #666666;&quot;&gt;&amp;quot;&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;;
                buffer.&lt;span style=&quot;color: #00eeff;&quot;&gt;replace&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;QByteArray&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #666666;&quot;&gt;&amp;quot;&lt;span style=&quot;color: #666666; font-weight: bold;&quot;&gt;\r&lt;/span&gt;&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;, QByteArray&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #666666;&quot;&gt;&amp;quot;&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;;
                &lt;span style=&quot;color: #0000ff;&quot;&gt;int&lt;/span&gt; sepIndex = buffer.&lt;span style=&quot;color: #00eeff;&quot;&gt;indexOf&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #666666;&quot;&gt;'x'&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;;
                &lt;span style=&quot;color: #0000ff;&quot;&gt;int&lt;/span&gt; resX = buffer.&lt;span style=&quot;color: #00eeff;&quot;&gt;left&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;sepIndex&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;.&lt;span style=&quot;color: #00eeff;&quot;&gt;toInt&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;;
                &lt;span style=&quot;color: #0000ff;&quot;&gt;int&lt;/span&gt; resY = buffer.&lt;span style=&quot;color: #00eeff;&quot;&gt;mid&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;sepIndex&lt;span style=&quot;color: #0000dd;&quot;&gt;+1&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;.&lt;span style=&quot;color: #00eeff;&quot;&gt;toInt&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;;
                renderTarget-&amp;gt;setMinimumSize&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;resX, resY&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;;
            &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#125;&lt;/span&gt;
            &lt;span style=&quot;color: #ff0000;&quot;&gt;// réponse à get_time_length : ANS_LENGTH=45.28&lt;/span&gt;
            &lt;span style=&quot;color: #0000ff;&quot;&gt;if&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;buffer.&lt;span style=&quot;color: #00eeff;&quot;&gt;startsWith&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #666666;&quot;&gt;&amp;quot;ANS_LENGTH&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;
            &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#123;&lt;/span&gt;
                buffer.&lt;span style=&quot;color: #0000dd;&quot;&gt;remove&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0000dd;&quot;&gt;0&lt;/span&gt;, &lt;span style=&quot;color: #0000dd;&quot;&gt;11&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;;
                buffer.&lt;span style=&quot;color: #00eeff;&quot;&gt;replace&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;QByteArray&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #666666;&quot;&gt;&amp;quot;'&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;, QByteArray&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #666666;&quot;&gt;&amp;quot;&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;;
                buffer.&lt;span style=&quot;color: #00eeff;&quot;&gt;replace&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;QByteArray&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #666666;&quot;&gt;&amp;quot; &amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;, QByteArray&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #666666;&quot;&gt;&amp;quot;&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;;
                buffer.&lt;span style=&quot;color: #00eeff;&quot;&gt;replace&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;QByteArray&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #666666;&quot;&gt;&amp;quot;&lt;span style=&quot;color: #666666; font-weight: bold;&quot;&gt;\n&lt;/span&gt;&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;, QByteArray&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #666666;&quot;&gt;&amp;quot;&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;;
                buffer.&lt;span style=&quot;color: #00eeff;&quot;&gt;replace&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;QByteArray&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #666666;&quot;&gt;&amp;quot;&lt;span style=&quot;color: #666666; font-weight: bold;&quot;&gt;\r&lt;/span&gt;&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;, QByteArray&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #666666;&quot;&gt;&amp;quot;&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;;
                &lt;span style=&quot;color: #0000ff;&quot;&gt;float&lt;/span&gt; maxTime = buffer.&lt;span style=&quot;color: #00eeff;&quot;&gt;toFloat&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;;
                timeLine-&amp;gt;setMaximum&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;static_cast&amp;lt;int&amp;gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;maxTime&lt;span style=&quot;color: #0000dd;&quot;&gt;+1&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;;
            &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#125;&lt;/span&gt;
            &lt;span style=&quot;color: #ff0000;&quot;&gt;// réponse à get_time_pos : ANS_TIME_POSITION=2.4&lt;/span&gt;
            &lt;span style=&quot;color: #0000ff;&quot;&gt;if&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;buffer.&lt;span style=&quot;color: #00eeff;&quot;&gt;startsWith&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #666666;&quot;&gt;&amp;quot;ANS_TIME_POSITION&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;
            &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#123;&lt;/span&gt;
                buffer.&lt;span style=&quot;color: #0000dd;&quot;&gt;remove&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0000dd;&quot;&gt;0&lt;/span&gt;, &lt;span style=&quot;color: #0000dd;&quot;&gt;18&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;;
                buffer.&lt;span style=&quot;color: #00eeff;&quot;&gt;replace&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;QByteArray&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #666666;&quot;&gt;&amp;quot;'&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;, QByteArray&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #666666;&quot;&gt;&amp;quot;&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;;
                buffer.&lt;span style=&quot;color: #00eeff;&quot;&gt;replace&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;QByteArray&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #666666;&quot;&gt;&amp;quot; &amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;, QByteArray&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #666666;&quot;&gt;&amp;quot;&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;;
                buffer.&lt;span style=&quot;color: #00eeff;&quot;&gt;replace&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;QByteArray&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #666666;&quot;&gt;&amp;quot;&lt;span style=&quot;color: #666666; font-weight: bold;&quot;&gt;\n&lt;/span&gt;&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;, QByteArray&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #666666;&quot;&gt;&amp;quot;&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;;
                buffer.&lt;span style=&quot;color: #00eeff;&quot;&gt;replace&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;QByteArray&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #666666;&quot;&gt;&amp;quot;&lt;span style=&quot;color: #666666; font-weight: bold;&quot;&gt;\r&lt;/span&gt;&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;, QByteArray&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #666666;&quot;&gt;&amp;quot;&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;;
                &lt;span style=&quot;color: #0000ff;&quot;&gt;float&lt;/span&gt; currTime = buffer.&lt;span style=&quot;color: #00eeff;&quot;&gt;toFloat&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;;
                timeLine-&amp;gt;setValue&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;static_cast&amp;lt;int&amp;gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;currTime&lt;span style=&quot;color: #0000dd;&quot;&gt;+1&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;;
            &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#125;&lt;/span&gt;
        &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#125;&lt;/span&gt;
    &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#125;&lt;/span&gt;
&amp;nbsp;
    &lt;span style=&quot;color: #0000ff;&quot;&gt;void&lt;/span&gt; pollCurrentTime&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;
    &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#123;&lt;/span&gt;
        mplayerProcess-&amp;gt;write&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #666666;&quot;&gt;&amp;quot;get_time_pos&lt;span style=&quot;color: #666666; font-weight: bold;&quot;&gt;\n&lt;/span&gt;&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;;
    &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#125;&lt;/span&gt;
&amp;nbsp;
    &lt;span style=&quot;color: #ff0000;&quot;&gt;// Dirige la timeline&lt;/span&gt;
    &lt;span style=&quot;color: #0000ff;&quot;&gt;void&lt;/span&gt; timeLineChanged&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0000ff;&quot;&gt;int&lt;/span&gt; pos&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;
    &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#123;&lt;/span&gt;
        mplayerProcess-&amp;gt;write&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;QString&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #666666;&quot;&gt;&amp;quot;seek &amp;quot;&lt;/span&gt; + QString::&lt;span style=&quot;color: #00eeff;&quot;&gt;number&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;pos&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt; + &lt;span style=&quot;color: #666666;&quot;&gt;&amp;quot; 2&lt;span style=&quot;color: #666666; font-weight: bold;&quot;&gt;\n&lt;/span&gt;&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;.&lt;span style=&quot;color: #00eeff;&quot;&gt;toUtf8&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;;
    &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#125;&lt;/span&gt;
&amp;nbsp;
    &lt;span style=&quot;color: #ff0000;&quot;&gt;// Play/stop&lt;/span&gt;
    &lt;span style=&quot;color: #0000ff;&quot;&gt;void&lt;/span&gt; switchPlayState&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;
    &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#123;&lt;/span&gt;
        &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#91;&lt;/span&gt;...&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#93;&lt;/span&gt;
    &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#125;&lt;/span&gt;
&amp;nbsp;
    &lt;span style=&quot;color: #0000ff;&quot;&gt;void&lt;/span&gt; mplayerEnded&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0000ff;&quot;&gt;int&lt;/span&gt; exitCode, QProcess::&lt;span style=&quot;color: #00eeff;&quot;&gt;ExitStatus&lt;/span&gt; exitStatus&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;
    &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#123;&lt;/span&gt;
        &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#91;&lt;/span&gt;...&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#93;&lt;/span&gt;
    &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#125;&lt;/span&gt;
&amp;nbsp;
&lt;span style=&quot;color: #0000ff;&quot;&gt;private&lt;/span&gt;:
    &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#91;&lt;/span&gt;...&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#93;&lt;/span&gt;
    QWidget *renderTarget;
    QProcess *mplayerProcess;
    &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#91;&lt;/span&gt;...&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#93;&lt;/span&gt;
&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#125;&lt;/span&gt;;&lt;/pre&gt;


&lt;h3&gt;Si vous avez des remarques...&lt;/h3&gt;

&lt;p&gt;Si vous avez besoin d'un éclaircissement, vous pouvez le faire &lt;a href=&quot;http://qtfr.org/forum/viewtopic.php?pid=14373#p14373&quot;&gt;ici&lt;/a&gt;.&lt;/p&gt;</description>
    
          <enclosure url="http://doc.qtfr.org/public/2007/qt_mplayer.tar.gz"
      length="2452" type="application/x-gzip" />
    
    
          <comments>http://doc.qtfr.org/post/2007/03/21/Un-conteneur-pour-MPlayer-utilisation-de-QProcess#comment-form</comments>
      <wfw:comment>http://doc.qtfr.org/post/2007/03/21/Un-conteneur-pour-MPlayer-utilisation-de-QProcess#comment-form</wfw:comment>
      <wfw:commentRss>http://doc.qtfr.org/feed/rss2/comments/95</wfw:commentRss>
      </item>
    
  <item>
    <title>Intégration de VLC</title>
    <link>http://doc.qtfr.org/post/2007/02/21/Integration-de-VLC</link>
    <guid isPermaLink="false">urn:md5:65c3d5b954ca0f9de7cf8e553dab58a0</guid>
    <pubDate>Wed, 21 Feb 2007 22:55:00 +0100</pubDate>
    <dc:creator>lud42fr</dc:creator>
        <category>Tutoriels</category>
        <category>class_QWidget</category><category>intégration</category><category>version_Qt3</category><category>version_Qt4</category><category>VLC</category>    
    <description>&lt;ul&gt;
&lt;li&gt;Comment intégrer VLC dans une application Qt&amp;nbsp;?&lt;/li&gt;
&lt;li&gt;Comment visualiser une vidéo dans une applicaiton Qt&amp;nbsp;?&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Ce tutoriel va explorer l'intégration de la bibliothèque VLC dans Qt, pour la lecture de fichier.&lt;/p&gt;


&lt;p&gt;&lt;strong&gt;Version&lt;/strong&gt;&amp;nbsp;: Qt3, Qt4 &lt;br /&gt;
&lt;strong&gt;Auteur&lt;/strong&gt;&amp;nbsp;: Ludo (&lt;a href=&quot;http://forum.qtfr.org/profile.php?id=1041&quot;&gt;lud42fr&lt;/a&gt;) &lt;br /&gt;
&lt;strong&gt;Status&lt;/strong&gt;&amp;nbsp;: basé sur la version SVN 0.9.0 de l’API VLC (devrait egalement fonctionner avec une version &amp;gt;= 0.8.6)&lt;/p&gt;    &lt;h3&gt;Introduction&lt;/h3&gt;


&lt;p&gt;Qt, dans son souci de framework généraliste, n’implémente pas toujours tout ce dont on peut avoir besoin, surtout lorsque cela n’est pas d’usage courant. Les vidéos font partie de ce qui n’est pas couvert par Qt. Cependant, un grand nombre de librairies et autres backends existent. Nous allons voir comment utiliser l’une d’entre elle: &lt;a href=&quot;http://www.videolan.org/&quot; hreflang=&quot;en&quot;&gt;VLC&lt;/a&gt;.&lt;/p&gt;



&lt;h3&gt;Pré-requis&lt;/h3&gt;


&lt;p&gt;Voici ce dont vous aurez besoin&amp;nbsp;:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Les librairies VLC &amp;gt;= 0.8.6 &lt;a href=&quot;http://www.videolan.org/vlc/&quot; hreflang=&quot;en&quot;&gt;(Page de téléchargement)&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;La documentation des &lt;a href=&quot;http://www.videolan.org/developers/vlc/doc/doxygen/html/modules.html&quot; title=&quot;en&quot;&gt;fonctions internes de VLC&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;Il semblerait que VLC soit &lt;em&gt;difficilement compilable sous Visual C++&lt;/em&gt;. Comme ce tutoriel suppose de pouvoir lier votre application avec les libraires VLC, les personnes désireuses de développer sous Windows devront utiliser Mingw pour générer leur application.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Pour compiler VLC 0.9.0 (la version actuellement en cours de développement, récupérable depuis le SVN), vous aurez besoin de&amp;nbsp;:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;bibliothèque MAD (MPEG Audio Decoder)&amp;nbsp;: &lt;a href=&quot;http://www.underbit.com/products/mad/&quot; title=&quot;http://www.underbit.com/products/mad/&quot;&gt;http://www.underbit.com/products/ma...&lt;/a&gt; ou mettre une option lors du &lt;code&gt;configure&lt;/code&gt; pour la désactiver,&lt;/li&gt;
&lt;li&gt;FFMpeg&amp;nbsp;: &lt;a href=&quot;http://ffmpeg.mplayerhq.hu/&quot; title=&quot;http://ffmpeg.mplayerhq.hu/&quot;&gt;http://ffmpeg.mplayerhq.hu/&lt;/a&gt;,&lt;/li&gt;
&lt;li&gt;liba52&amp;nbsp;: &lt;a href=&quot;http://liba52.sf.net&quot; title=&quot;http://liba52.sf.net&quot;&gt;http://liba52.sf.net&lt;/a&gt;,&lt;/li&gt;
&lt;li&gt;libmpeg2&amp;nbsp;: &lt;a href=&quot;http://libmpeg2.sf.net&quot; title=&quot;http://libmpeg2.sf.net&quot;&gt;http://libmpeg2.sf.net&lt;/a&gt;.&lt;/li&gt;
&lt;/ul&gt;


&lt;h3&gt;Lecteur vidéo&lt;/h3&gt;


&lt;p&gt;Ce tutoriel détaille la manière d'utiliser l'API VLC au travers d'une application Qt.&lt;/p&gt;


&lt;p&gt;L’avantage de cette méthode est que le contrôle de VLC est plus simple et précis et ne nécessite pas d’exécuter/piloter un processus externe (contrairement à l'utilisation de MPlayer).&lt;/p&gt;


&lt;p&gt;Nous allons créer un petit exemple simple de lecteur vidéo, ce dernier permettant&amp;nbsp;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;d’initialiser VLC,&lt;/li&gt;
&lt;li&gt;de charger un flux vidéo,&lt;/li&gt;
&lt;li&gt;de naviguer dans la vidéo (avance/retour),&lt;/li&gt;
&lt;li&gt;de modifier le volume.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Une image valant mieux qu'un long discours, voici une capture d'écran du résultat final&amp;nbsp;:&lt;/p&gt;


&lt;p&gt;&lt;a href=&quot;http://doc.qtfr.org/public/2006/vlc.jpg&quot;&gt;&lt;img src=&quot;http://doc.qtfr.org/public/2006/.vlc_m.jpg&quot; alt=&quot;vlc.jpg&quot; style=&quot;display:block; margin:0 auto;&quot; /&gt;&lt;/a&gt;&lt;/p&gt;


&lt;p&gt;&lt;a href=&quot;http://doc.qtfr.org/public/2007/qt_vlc.zip&quot;&gt;Le code de ce tutorial (source + .pro)&lt;/a&gt;&lt;/p&gt;


&lt;h4&gt;Compilation&lt;/h4&gt;


&lt;p&gt;La compilation de l’exemple nécessite bien entendu les includes et les libraires de VLC.
Celles ci doivent êtres dans dans les chemins de recherche&lt;/p&gt;


&lt;h5&gt;Linux/Unix&lt;/h5&gt;


&lt;p&gt;Voici le fichier pro typique&amp;nbsp;:&lt;/p&gt;
&lt;pre&gt;
TEMPLATE = app
DEPENDPATH += .
INCLUDEPATH += . 
SOURCES += tuto_vlc.cpp
LIBS+=-lvlc
&lt;/pre&gt;



&lt;h3&gt;Explications&lt;/h3&gt;


&lt;p&gt;Si l'on résume les étapes nécessaires à la lecture d'un vidéo dans une application Qt&amp;nbsp;:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;initialiser un contexte VLC,&lt;/li&gt;
&lt;li&gt;ajouter un flux à la playlist,&lt;/li&gt;
&lt;li&gt;rediriger la fenêtre vidéo de sortie vlc sur un widget Qt de l'application,&lt;/li&gt;
&lt;li&gt;démarrer la lecture du flux.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Certaines fonctions de l'API de VLC seront détaillées. Toutes ces fonctions et bien plus encore sont disponibles dans la &lt;a href=&quot;http://www.videolan.org/developers/vlc/doc/doxygen/html/modules.html&quot; hreflang=&quot;en&quot;&gt;documentation de VLC&lt;/a&gt;.&lt;/p&gt;



&lt;h4&gt;Initialisation d'un contexte VLC&lt;/h4&gt;


&lt;p&gt;Normalement seule l'inclusion de l'entête vlc/libvlc.h est nécessaire pour utiliser toutes les fonctions VLC.&lt;/p&gt;


&lt;pre&gt;#include &amp;lt;vlc/libvlc.h&amp;gt;&lt;/pre&gt;


&lt;p&gt;VLC reporte toutes ses erreurs dans une structure particulière &lt;code&gt;libvlc_exception_t&lt;/code&gt;. Avant tout appel à une fonction VLC, il nous faudra donc une telle structure&amp;nbsp;:&lt;/p&gt;

&lt;pre class=&quot;cpp&quot;&gt;libvlc_exception_t _vlcexcep; &lt;span style=&quot;color: #ff0000;&quot;&gt;//déclaration de la structure&lt;/span&gt;
libvlc_exception_init &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&amp;amp;_vlcexcep&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;; &lt;span style=&quot;color: #ff0000;&quot;&gt;//initialisation de la structure&lt;/span&gt;&lt;/pre&gt;


&lt;p&gt;Quelques fonctions pratiques à utiliser avec &lt;code&gt;libvlc_exception_t&lt;/code&gt;&amp;nbsp;:&lt;/p&gt;

&lt;pre class=&quot;cpp&quot;&gt;&lt;span style=&quot;color: #0000ff;&quot;&gt;if&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;libvlc_exception_raised&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&amp;amp;_vlcexcep&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;!=&lt;span style=&quot;color: #0000dd;&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#123;&lt;/span&gt;....&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#125;&lt;/span&gt; &lt;span style=&quot;color: #ff0000;&quot;&gt;//teste si une erreur a eu lieu.&lt;/span&gt;
libvlc_exception_get_message&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&amp;amp;_vlcexcep&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;; &lt;span style=&quot;color: #ff0000;&quot;&gt;//retourne le message d'erreur&lt;/span&gt;
libvlc_exception_clear&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&amp;amp;_vlcexcep&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;; &lt;span style=&quot;color: #ff0000;&quot;&gt;//efface la/les erreurs précédentes&lt;/span&gt;&lt;/pre&gt;


&lt;p&gt;Il est maintenant temps de créer un contexte VLC, de type &lt;code&gt;libvlc_instance_t&lt;/code&gt;, nécessaire à la plupart des fonctions&amp;nbsp;:&lt;/p&gt;

&lt;pre class=&quot;cpp&quot;&gt;libvlc_instance_t *_vlcinstance;
_vlcinstance=libvlc_new&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;argc,argv,&amp;amp;_vlcexcep&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;/pre&gt;


&lt;p&gt;Il n'est possible de lire qu'un seul flux vidéo à la fois par contexte. Pour lire plusieurs flux en parallèle, il faut donc initialiser plusieurs contextes. Lorsqu'un contexte, n'est plus utile, ne pas oublier de le libérer&amp;nbsp;:&lt;/p&gt;


&lt;pre&gt;libvlc_destroy (_vlcinstance, &amp;amp;_vlcexcep);&lt;/pre&gt;



&lt;h4&gt;Ajout d'un flux&lt;/h4&gt;


&lt;p&gt;Le chargement d'un flux vidéo se fait dans un contexte initialisé et dans l'élément playlist de VLC (se réfèrer à la doc quant à la gestion des playlist, ce tutoriel n'en faisant pas d'autres mentions).&lt;/p&gt;

&lt;pre class=&quot;cpp&quot;&gt;libvlc_playlist_clear&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;_vlcinstance,&amp;amp;_vlcexcep&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;; &lt;span style=&quot;color: #ff0000;&quot;&gt;//on vide la playlist&lt;/span&gt;
libvlc_playlist_add &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;_vlcinstance,URL,&lt;span style=&quot;color: #0000ff;&quot;&gt;NULL&lt;/span&gt;,&amp;amp;_vlcexcep&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;span style=&quot;color: #ff0000;&quot;&gt;//on ajoute le nouveau flux&lt;/span&gt;&lt;/pre&gt;


&lt;blockquote&gt;&lt;p&gt;&lt;strong&gt;Note&lt;/strong&gt;&amp;nbsp;: à ce niveau, le fichier est dans la playlist, il n'est pas en cours de lecture ou n'a pas interrompu la lecture en cours.&lt;/p&gt;&lt;/blockquote&gt;


&lt;p&gt;Avec URL une chaine de caractère de la forme (principalement)&amp;nbsp;:&lt;/p&gt;

&lt;table&gt;
&lt;tr&gt;&lt;th&gt;Type&lt;/th&gt;          &lt;th&gt;Forme&lt;/th&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;Fichier local&lt;/td&gt; &lt;td&gt;file://chemin&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;Url http&lt;/td&gt;      &lt;td&gt;http://ip:port/file&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;Fichier ftp&lt;/td&gt;   &lt;td&gt;ftp://ip:port/file&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;DVD&lt;/td&gt;           &lt;td&gt;dvd://[device]&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;Flux UDP&lt;/td&gt;      &lt;td&gt;udp:[&lt;source address=&quot;&quot;&gt;]@[&lt;bind address=&quot;&quot;&gt;][:&lt;bind port=&quot;&quot;&gt;]%% &lt;/bind&gt;&lt;/bind&gt;&lt;/source&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;




&lt;h4&gt;Redirection du flux sur un widget Qt&lt;/h4&gt;


&lt;p&gt;La redirection de la sortie vidéo sur un widget de l'application est une des étapes les plus importantes pour l'intégration (ce n'est pas la plus compliquée ;-) ).&lt;/p&gt;


&lt;p&gt;A noter que VLC, se chargera d'adapter la taille de la vidéo à la taille du widget tout en conservant l'aspect de la video (VLC se chargera aussi de resizer la video si la taille du widget venait a changer en cours de lecture).&lt;/p&gt;


&lt;p&gt;N'importe quel widget peut servir pour afficher une video, mais dans la mesure ou il sera complètement recouvert, un simple &lt;code&gt;QWidget&lt;/code&gt; suffit.&lt;/p&gt;


&lt;pre&gt;//Notez l'usage de Widget-&amp;gt;winId() pour indiquer on dessiner la video
libvlc_video_set_parent(_vlcinstance ,Widget-&amp;gt;winId(),&amp;amp;_vlcexcep);&lt;/pre&gt;



&lt;h4&gt;Functions vidéos/audios&lt;/h4&gt;


&lt;p&gt;Certaines fonctions requièrent un pointeur sur libvlc_input_t .Pour obtenir ce pointeur, un flux doit etre en cours de lecture/pause&amp;nbsp;:&lt;/p&gt;


&lt;pre&gt;libvlc_input_t *input=libvlc_playlist_get_input (_vlcinstance,&amp;amp;_vlcexcep); //obtenir un pointeur input
libvlc_input_free (input); //il est en general de bon ton de libérer input après usage&lt;/pre&gt;



&lt;h5&gt;Contrôle de la vidéo&lt;/h5&gt;

&lt;ul&gt;
&lt;li&gt;Démarrer la lecture&amp;nbsp;:&lt;/li&gt;
&lt;/ul&gt;

&lt;pre&gt;libvlc_playlist_play (_vlcinstance , -1, 0, NULL, &amp;amp;_vlcexcep);
// avec :
//          -1 pour indiquer de lire l'element suivant de la playlist
//          0 le nombre d'option a passer au flux a lire
//          NULL : les options&lt;/pre&gt;

&lt;ul&gt;
&lt;li&gt;Stopper la lecture&amp;nbsp;:&lt;/li&gt;
&lt;/ul&gt;

&lt;pre&gt;libvlc_playlist_stop (_vlcinstance, &amp;amp;_vlcexcep);&lt;/pre&gt;

&lt;ul&gt;
&lt;li&gt;Mettre en pause la lecture&amp;nbsp;:&lt;/li&gt;
&lt;/ul&gt;

&lt;pre&gt;libvlc_playlist_pause (_vlcinstance, &amp;amp;_vlcexcep);&lt;/pre&gt;

&lt;ul&gt;
&lt;li&gt;Connaître l'état&amp;nbsp;:&lt;/li&gt;
&lt;/ul&gt;

&lt;pre&gt;int etat=libvlc_playlist_isplaying(_vlcinstance, &amp;amp;_vlcexcep);
//etat=0 si stop ou pause
//etat=1 si lecture en cours&lt;/pre&gt;

&lt;ul&gt;
&lt;li&gt;Lire en boucle&amp;nbsp;:&lt;/li&gt;
&lt;/ul&gt;

&lt;pre&gt;int loop=1; //mettre a 0 pour stopper la lecture en boucle
libvlc_playlist_loop (_vlcinstance, loop,&amp;amp;_vlcexcep);&lt;/pre&gt;

&lt;ul&gt;
&lt;li&gt;Connaître la durée totale du flux (nécessite un pointeur input)&amp;nbsp;:&lt;/li&gt;
&lt;/ul&gt;

&lt;pre&gt;long long duree=libvlc_input_get_length (input, &amp;amp;_vlcexcep);&lt;/pre&gt;

&lt;ul&gt;
&lt;li&gt;Connaître la position actuelle en ms (nécessite un pointeur input)&amp;nbsp;:&lt;/li&gt;
&lt;/ul&gt;

&lt;pre&gt;long long position=libvlc_input_get_time (input, &amp;amp;_vlcexcep);&lt;/pre&gt;

&lt;ul&gt;
&lt;li&gt;Se positionner dans le flux (position en ms - nécessite un pointeur input)&amp;nbsp;:&lt;/li&gt;
&lt;/ul&gt;

&lt;pre&gt;libvlc_input_set_time (input, 42000,&amp;amp;_vlcexcep); //se positionne a 42 sec&lt;/pre&gt;

&lt;ul&gt;
&lt;li&gt;Connaître la position actuelle en pourcentage (nécessite un pointeur input)&amp;nbsp;:&lt;/li&gt;
&lt;/ul&gt;

&lt;pre&gt;float posEnPourcent=libvlc_input_get_position (input, &amp;amp;_vlcexcep)*100.0;&lt;/pre&gt;

&lt;ul&gt;
&lt;li&gt;Se positionner dans le flux (position en pourcentage du temps total - nécessite un pointeur input)&amp;nbsp;:&lt;/li&gt;
&lt;/ul&gt;

&lt;pre&gt;libvlc_input_set_position(input, 0.42f,&amp;amp;_vlcexcep); // se positionne a 42% du flux ???&lt;/pre&gt;



&lt;h5&gt;Contrôle du volume&lt;/h5&gt;

&lt;ul&gt;
&lt;li&gt;Obtenir la valeur du volume comprise entre 0 et 100 - 0 étant le minimum&amp;nbsp;:&lt;/li&gt;
&lt;/ul&gt;

&lt;pre&gt;int volume=libvlc_audio_get_volume (_vlcinstance, &amp;amp;_vlcexcep);&lt;/pre&gt;

&lt;ul&gt;
&lt;li&gt;Positionner le volume (valeur en 0 et 100)&amp;nbsp;:&lt;/li&gt;
&lt;/ul&gt;

&lt;pre&gt;libvlc_audio_set_volume (_vlcinstance, 42,&amp;amp;_vlcexcep); //volume a 42%&lt;/pre&gt;</description>
    
          <enclosure url="http://doc.qtfr.org/public/2007/qt_vlc.zip"
      length="2792" type="application/zip" />
    
    
          <comments>http://doc.qtfr.org/post/2007/02/21/Integration-de-VLC#comment-form</comments>
      <wfw:comment>http://doc.qtfr.org/post/2007/02/21/Integration-de-VLC#comment-form</wfw:comment>
      <wfw:commentRss>http://doc.qtfr.org/feed/rss2/comments/51</wfw:commentRss>
      </item>
    
  <item>
    <title>Intégration de SDL</title>
    <link>http://doc.qtfr.org/post/2007/02/21/Integration-de-SDL</link>
    <guid isPermaLink="false">urn:md5:117b6f909d42194f825db6c03e8c805c</guid>
    <pubDate>Wed, 21 Feb 2007 13:11:00 +0100</pubDate>
    <dc:creator>IrmatDen</dc:creator>
        <category>Tutoriels</category>
        <category>class_QWidget</category><category>intégration</category><category>SDL</category><category>version_Qt3</category><category>version_Qt4</category>    
    <description>&lt;ul&gt;
&lt;li&gt;Comment intégrer SDL dans un widget Qt&amp;nbsp;?&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Ce tutoriel va explorer l'intégration de la bibliothèque SDL dans Qt, le rendu étant effectué dans un widget Qt.&lt;/p&gt;


&lt;p&gt;&lt;strong&gt;Version&lt;/strong&gt;&amp;nbsp;: Qt4 (Qt3 possible avec quelques ajustements) &lt;br /&gt;
&lt;strong&gt;Auteur&lt;/strong&gt;&amp;nbsp;: Denys Bulant (&lt;a href=&quot;http://forum.qtfr.org/profile.php?id=291&quot;&gt;IrmatDen&lt;/a&gt;)&lt;/p&gt;    &lt;h3&gt;Pré requis:&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;http://www.libsdl.org/&quot; hreflang=&quot;en&quot;&gt;La librairie SDL&lt;/a&gt;&amp;nbsp;: le site contient une section documentation pour débuter&lt;/li&gt;
&lt;/ul&gt;


&lt;h3&gt;Un widget Qt comme cible de rendu pour SDL&lt;/h3&gt;


&lt;p&gt;Les moteurs graphiques des différents Qt ne sont souvent pas adaptés au travail graphique intense (sauf à passer par OpenGL, mais on détourne le problème - c'est d'ailleurs ce que l'on va faire ici).&lt;/p&gt;


&lt;h4&gt;Signifier à SDL la fenêtre à utiliser&lt;/h4&gt;


&lt;p&gt;Se servir d'un widget comme zone de rendu cible pour SDL est très simple: il suffit d'une variable d'environnement. Cette variable est &lt;code&gt;SDL_WINDOWID&lt;/code&gt; et peut être de 2 formats:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;un entier, tel quel&lt;/li&gt;
&lt;li&gt;une valeur hexadécimale, préfixé par '0x'&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Une variable valide est un handle de fenêtre (dont le format peut varier en fonction de l'environnement utilisé). Ce handle s'obtient par la méthode &lt;code&gt;&lt;a href=&quot;http://doc.trolltech.com/4.2/qwidget.html#winId&quot; hreflang=&quot;en&quot;&gt;QWidget::winId()&lt;/a&gt;&lt;/code&gt;, qui est une méthode publique.&lt;/p&gt;


&lt;p&gt;Une fois la zone de rendu définie par cette variable, on peut initialiser le moteur graphique de SDL.
Voici par exemple le code permettant de réaliser cette intégration&amp;nbsp;:&lt;/p&gt;

&lt;pre class=&quot;cpp&quot;&gt;&lt;span style=&quot;color: #0000ff;&quot;&gt;char&lt;/span&gt; windowid&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span style=&quot;color: #0000dd;&quot;&gt;64&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#93;&lt;/span&gt;;
&lt;span style=&quot;color: #339900;&quot;&gt;#ifdef Q_WS_WIN&lt;/span&gt;
	&lt;span style=&quot;color: #0000dd;&quot;&gt;sprintf&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;windowid, &lt;span style=&quot;color: #666666;&quot;&gt;&amp;quot;SDL_WINDOWID=0x%lx&amp;quot;&lt;/span&gt;, reinterpret_cast&amp;lt;qlonglong&amp;gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;winId&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;;
&lt;span style=&quot;color: #339900;&quot;&gt;#elif defined Q_WS_X11&lt;/span&gt;
	&lt;span style=&quot;color: #0000dd;&quot;&gt;sprintf&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;windowid, &lt;span style=&quot;color: #666666;&quot;&gt;&amp;quot;SDL_WINDOWID=0x%lx&amp;quot;&lt;/span&gt;, winId&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;;
&lt;span style=&quot;color: #339900;&quot;&gt;#else&lt;/span&gt;
	qFatal&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #666666;&quot;&gt;&amp;quot;Fatal: cast du winId() inconnu pour votre plate-forme; toute information est la bienvenue!&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;;
&lt;span style=&quot;color: #339900;&quot;&gt;#endif&lt;/span&gt;
SDL_putenv&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;windowid&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;;
&lt;span style=&quot;color: #ff0000;&quot;&gt;// Initialisation du système vidéo de SDL&lt;/span&gt;
SDL_Init&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;SDL_INIT_VIDEO&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;;
screen = SDL_SetVideoMode&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;width&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;, height&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;, &lt;span style=&quot;color: #0000dd;&quot;&gt;32&lt;/span&gt;, SDL_SWSURFACE&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;/pre&gt;


&lt;blockquote&gt;&lt;p&gt;&lt;strong&gt;Attention&lt;/strong&gt;&amp;nbsp;: ne le faîtes pas l'initialisation du système vidéo de SDL avant que la création réelle de votre widget (le moment le plus sûr est lors du premier showEvent), sinon une seconde fenêtre sera créée par et pour SDL.&lt;/p&gt;&lt;/blockquote&gt;


&lt;h4&gt;Configuration du widget de rendu&lt;/h4&gt;


&lt;p&gt;Le dessin direct par SDL sur un widget Qt implique une petite configuration des attributs de dessin du dit widget:&lt;/p&gt;
&lt;pre class=&quot;cpp&quot;&gt;setAttribute&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;Qt::&lt;span style=&quot;color: #00eeff;&quot;&gt;WA_PaintOnScreen&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;;
setAttribute&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;Qt::&lt;span style=&quot;color: #00eeff;&quot;&gt;WA_NoSystemBackground&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;/pre&gt;


&lt;p&gt;A faire lors de l'utilisation de SDL, sinon, vous aurez une bouillie de pixels &quot;inspirée&quot; par le fond de l'écran à cet emplacement ;)&lt;/p&gt;


&lt;h4&gt;Conflit de main&lt;/h4&gt;


&lt;p&gt;Il y a par contre un conflit entre SDL et Qt au niveau de la fonction &lt;code&gt;main&lt;/code&gt;. Lorsque &lt;code&gt;main&lt;/code&gt; n'est pas le point d'entrée d'un programme (ce qui est le cas sur win32 par exemple), Qt appelle main à partir de son implémentation de &lt;code&gt;WinMain&lt;/code&gt;. SDL quant à lui fait un define (code extrait de &lt;code&gt;SDL_main.h&lt;/code&gt;)&amp;nbsp;:&lt;/p&gt;

&lt;pre class=&quot;cpp&quot;&gt;&lt;span style=&quot;color: #339900;&quot;&gt;#define main SDL_main&lt;/span&gt;
&lt;span style=&quot;color: #ff0000; font-style: italic;&quot;&gt;/* The prototype for the application's main() function */&lt;/span&gt;
&lt;span style=&quot;color: #0000ff;&quot;&gt;extern&lt;/span&gt; C_LINKAGE &lt;span style=&quot;color: #0000ff;&quot;&gt;int&lt;/span&gt; SDL_main&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0000ff;&quot;&gt;int&lt;/span&gt; argc, &lt;span style=&quot;color: #0000ff;&quot;&gt;char&lt;/span&gt; *argv&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#93;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;/pre&gt;


&lt;p&gt;Pour supprimer ce problème, ils vous faut annuler la définition de SDL, juste après l'inclusion de &lt;code&gt;SDL.h&lt;/code&gt;&amp;nbsp;:&lt;/p&gt;

&lt;pre class=&quot;cpp&quot;&gt;&lt;span style=&quot;color: #339900;&quot;&gt;#include &amp;quot;SDL.h&amp;quot;&lt;/span&gt;
&lt;span style=&quot;color: #339900;&quot;&gt;#undef main&lt;/span&gt;&lt;/pre&gt;


&lt;p&gt;Une fois ceci fait, vous pouvez utiliser sereinement le système vidéo de SDL au sein de votre application Qt :)&lt;/p&gt;



&lt;h3&gt;Modification du fichier projet&lt;/h3&gt;


&lt;p&gt;Comme toute librairie, son utilisation avec votre programme doit être expressément signalée sous peine d'erreurs de compilation et/ou de liaison. Les informations à ajouter dans le fichier projet sont&amp;nbsp;:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;le chemin vers les en-têtes SDL (ex: &lt;code&gt;INCLUDEPATH += /usr/local/include/&lt;/code&gt;)&lt;/li&gt;
&lt;li&gt;la librairie avec laquelle lier (et éventuellement son chemin) (ex: &lt;code&gt;LIBS += -L/usr/local/lib/ -lSDL&lt;/code&gt;)&lt;/li&gt;
&lt;/ul&gt;


&lt;h3&gt;Exemple complet&lt;/h3&gt;


&lt;p&gt;Vous trouverez associé à ce tutoriel &lt;a href=&quot;http://doc.qtfr.org/public/2006/qt_sdl.tar.gz&quot;&gt;un exemple&lt;/a&gt; illustrant l'utilisation de la SDL pour un starfield - qui rappellera des souvenirs aux (ex-)possesseurs de vieilles machines et qui ont codé avant l’arrivée du S-VGA (définit comme étant haute-résolution à l’époque) ;-)&lt;/p&gt;


&lt;p&gt;J'ai repris ici les points principaux de la classe&amp;nbsp;:&lt;/p&gt;

&lt;pre class=&quot;cpp&quot;&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#91;&lt;/span&gt;...&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#93;&lt;/span&gt;
&amp;nbsp;
&lt;span style=&quot;color: #339900;&quot;&gt;#ifdef Q_WS_WIN&lt;/span&gt;
&lt;span style=&quot;color: #339900;&quot;&gt;#include &amp;lt;SDL.h&amp;gt;&lt;/span&gt;
&lt;span style=&quot;color: #339900;&quot;&gt;#elif defined Q_WS_X11&lt;/span&gt;
&lt;span style=&quot;color: #339900;&quot;&gt;#include &amp;lt;SDL/SDL.h&amp;gt;&lt;/span&gt;
&lt;span style=&quot;color: #339900;&quot;&gt;#endif&lt;/span&gt;
&amp;nbsp;
&lt;span style=&quot;color: #ff0000; font-style: italic;&quot;&gt;/* PIEGE: main est redéfini par SDL.h comme SDL_Main.
                On retire donc la définition puisque Qt le gère
*/&lt;/span&gt;
&lt;span style=&quot;color: #339900;&quot;&gt;#undef main&lt;/span&gt;
&amp;nbsp;
&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#91;&lt;/span&gt;...&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#93;&lt;/span&gt;
&amp;nbsp;
&lt;span style=&quot;color: #0000ff;&quot;&gt;class&lt;/span&gt; SDLWidget : &lt;span style=&quot;color: #0000ff;&quot;&gt;public&lt;/span&gt; QWidget
&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#123;&lt;/span&gt;
    Q_OBJECT
&amp;nbsp;
&lt;span style=&quot;color: #0000ff;&quot;&gt;public&lt;/span&gt;:
    SDLWidget&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;
    :refreshTimer&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0000dd;&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;, windowInitialized&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0000ff;&quot;&gt;false&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;, screen&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0000dd;&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;, StarNumbers&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0000dd;&quot;&gt;100&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;
    &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#123;&lt;/span&gt;
        &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#91;&lt;/span&gt;...&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#93;&lt;/span&gt;
    &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#125;&lt;/span&gt;
&amp;nbsp;
    &lt;span style=&quot;color: #0000ff;&quot;&gt;virtual&lt;/span&gt; ~SDLWidget&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;
    &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#123;&lt;/span&gt;
        SDL_Quit&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;;
    &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#125;&lt;/span&gt;
&amp;nbsp;
&lt;span style=&quot;color: #0000ff;&quot;&gt;protected&lt;/span&gt;:
    &lt;span style=&quot;color: #0000ff;&quot;&gt;virtual&lt;/span&gt; &lt;span style=&quot;color: #0000ff;&quot;&gt;void&lt;/span&gt; showEvent&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;QShowEvent *e&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;
    &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#123;&lt;/span&gt;
        &lt;span style=&quot;color: #0000ff;&quot;&gt;if&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;!windowInitialized&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;
        &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#123;&lt;/span&gt;
            &lt;span style=&quot;color: #ff0000;&quot;&gt;// C'est ici qu'on dis à SDL d'utiliser notre widget&lt;/span&gt;
            &lt;span style=&quot;color: #0000ff;&quot;&gt;char&lt;/span&gt; windowid&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span style=&quot;color: #0000dd;&quot;&gt;64&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#93;&lt;/span&gt;;
&lt;span style=&quot;color: #339900;&quot;&gt;#ifdef Q_WS_WIN&lt;/span&gt;
&amp;nbsp;
			&lt;span style=&quot;color: #0000dd;&quot;&gt;sprintf&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;windowid, &lt;span style=&quot;color: #666666;&quot;&gt;&amp;quot;SDL_WINDOWID=0x%lx&amp;quot;&lt;/span&gt;, reinterpret_cast&amp;lt;qlonglong&amp;gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;winId&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;;
&lt;span style=&quot;color: #339900;&quot;&gt;#elif defined Q_WS_X11&lt;/span&gt;
			&lt;span style=&quot;color: #0000dd;&quot;&gt;sprintf&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;windowid, &lt;span style=&quot;color: #666666;&quot;&gt;&amp;quot;SDL_WINDOWID=0x%lx&amp;quot;&lt;/span&gt;, winId&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;;
&lt;span style=&quot;color: #339900;&quot;&gt;#else&lt;/span&gt;
			qFatal&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #666666;&quot;&gt;&amp;quot;Fatal: cast du winId() inconnu pour votre plate-forme; toute information est la bienvenue!&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;;
&lt;span style=&quot;color: #339900;&quot;&gt;#endif&lt;/span&gt;
            SDL_putenv&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;windowid&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;;
&amp;nbsp;
            &lt;span style=&quot;color: #ff0000;&quot;&gt;// Initialisation du système vidéo de SDL&lt;/span&gt;
            SDL_Init&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;SDL_INIT_VIDEO&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;;
            screen = SDL_SetVideoMode&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;width&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;, height&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;, &lt;span style=&quot;color: #0000dd;&quot;&gt;32&lt;/span&gt;, SDL_SWSURFACE&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;;
            windowInitialized = &lt;span style=&quot;color: #0000ff;&quot;&gt;true&lt;/span&gt;;
        &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#125;&lt;/span&gt;
    &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#125;&lt;/span&gt;
&amp;nbsp;
&lt;span style=&quot;color: #0000ff;&quot;&gt;private&lt;/span&gt;:
    &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#91;&lt;/span&gt;...&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#93;&lt;/span&gt;
&amp;nbsp;
&lt;span style=&quot;color: #0000ff;&quot;&gt;private&lt;/span&gt;:
    &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#91;&lt;/span&gt;...&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#93;&lt;/span&gt;
&amp;nbsp;
&lt;span style=&quot;color: #0000ff;&quot;&gt;private&lt;/span&gt; slots:
    &lt;span style=&quot;color: #0000ff;&quot;&gt;void&lt;/span&gt; onRefresh&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;
    &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#123;&lt;/span&gt;
        &lt;span style=&quot;color: #0000ff;&quot;&gt;if&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;windowInitialized &amp;amp;&amp;amp; screen&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;
        &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#123;&lt;/span&gt;
            SDL_LockSurface&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;screen&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;;
                &lt;span style=&quot;color: #ff0000;&quot;&gt;// Nettoyage de l'écran&lt;/span&gt;
                SDL_FillRect&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;screen, &lt;span style=&quot;color: #0000ff;&quot;&gt;NULL&lt;/span&gt;, &lt;span style=&quot;color: #0000dd;&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;;
                &lt;span style=&quot;color: #ff0000;&quot;&gt;// Dessin du starfield&lt;/span&gt;
                drawStarfield&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;;
            SDL_UnlockSurface&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;screen&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;;
&amp;nbsp;
            &lt;span style=&quot;color: #ff0000;&quot;&gt;// Rafraîchissement...&lt;/span&gt;
            SDL_UpdateRect&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;screen, &lt;span style=&quot;color: #0000dd;&quot;&gt;0&lt;/span&gt;, &lt;span style=&quot;color: #0000dd;&quot;&gt;0&lt;/span&gt;, &lt;span style=&quot;color: #0000dd;&quot;&gt;0&lt;/span&gt;, &lt;span style=&quot;color: #0000dd;&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;;
&amp;nbsp;
            &lt;span style=&quot;color: #ff0000;&quot;&gt;// Et enfin, mise à jour des positions des étoiles&lt;/span&gt;
            updateStarfield&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;;
        &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#125;&lt;/span&gt;
    &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#125;&lt;/span&gt;
&amp;nbsp;
&lt;span style=&quot;color: #0000ff;&quot;&gt;private&lt;/span&gt;:
    &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#91;&lt;/span&gt;...&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#93;&lt;/span&gt;
&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#125;&lt;/span&gt;;&lt;/pre&gt;


&lt;p&gt;N’oubliez pas d’ajouter les références d’inclusion et de bibliothèques de SDL au .pro, et laissez vous aller à un peu de nostalgie ;-)&lt;/p&gt;


&lt;h3&gt;Utilisation avancée&lt;/h3&gt;


&lt;p&gt;L'ensemble du code illustrant l'utilisation décrite ici est disponible sur &lt;a href=&quot;http://doc.qtfr.org/public/2006/sdl_adv.tar.gz&quot;&gt;la seconde pièce jointe&lt;/a&gt;.&lt;/p&gt;


&lt;p&gt;La méthode décrite précédemment est suffisante si vous n'avez besoin de SDL que dans un seul widget. Mais si vous voulez utiliser SDL comme système d'affichage pour plusieurs widgets, alors il faut changer de stratégie. En effet, SDL ayant pris le parti d'utiliser une seule et unique variable d'environnement pointant vers un et un seul identifiant de fenêtre, il va nous falloir utiliser ce système différemment.&lt;/p&gt;


&lt;p&gt;Nous allons donc devoir créer un widget invisible servant à initialiser le système SDL. (Vous trouverez une classe remplissant cette fonctionnalité dans les fichiers tools.h et tools.cpp (classe &lt;code&gt;SDLContext&lt;/code&gt;) fournis avec l'archive.) Le dessin se fera alors sur diverses surfaces SDL (au moins 1 par widget où vous comptez l'utiliser en fait).&lt;/p&gt;


&lt;p&gt;Il nous font donc aussi des fonctions de conversion entre &lt;code&gt;QImage&lt;/code&gt; et &lt;code&gt;SDL_Surface&lt;/code&gt;, ainsi qu'une fonction de création de &lt;code&gt;SDL_Surface&lt;/code&gt;. Cette dernière est nécessaire afin de paramétrer les surfaces SDL de façon à ce que leur format soit compatible à 100% avec les formats proposés par &lt;code&gt;QImage&lt;/code&gt;. Dans l'exemple, ces fonctions ne couvrent pas tout les cas nécessaires, il ne tient qu'à vous de les compléter selon vos besoins:&lt;/p&gt;
&lt;pre class=&quot;cpp&quot;&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;// Création d'une surface SDL rapidement convertible en QImage&lt;/span&gt;
SDL_Surface* createQImageCompliantSurface&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;Uint32 flags, &lt;span style=&quot;color: #0000ff;&quot;&gt;int&lt;/span&gt; width, &lt;span style=&quot;color: #0000ff;&quot;&gt;int&lt;/span&gt; height&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;
&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#123;&lt;/span&gt;
	&lt;span style=&quot;color: #0000ff;&quot;&gt;static&lt;/span&gt; &lt;span style=&quot;color: #0000ff;&quot;&gt;const&lt;/span&gt; &lt;span style=&quot;color: #0000ff;&quot;&gt;int&lt;/span&gt; Rmask = 0x00FF0000;
	&lt;span style=&quot;color: #0000ff;&quot;&gt;static&lt;/span&gt; &lt;span style=&quot;color: #0000ff;&quot;&gt;const&lt;/span&gt; &lt;span style=&quot;color: #0000ff;&quot;&gt;int&lt;/span&gt; Gmask = 0x0000FF00;
	&lt;span style=&quot;color: #0000ff;&quot;&gt;static&lt;/span&gt; &lt;span style=&quot;color: #0000ff;&quot;&gt;const&lt;/span&gt; &lt;span style=&quot;color: #0000ff;&quot;&gt;int&lt;/span&gt; Bmask = 0x000000FF;
	&lt;span style=&quot;color: #0000ff;&quot;&gt;static&lt;/span&gt; &lt;span style=&quot;color: #0000ff;&quot;&gt;const&lt;/span&gt; &lt;span style=&quot;color: #0000ff;&quot;&gt;int&lt;/span&gt; Amask = 0xFF000000;
&amp;nbsp;
	&lt;span style=&quot;color: #0000ff;&quot;&gt;return&lt;/span&gt; SDL_CreateRGBSurface&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;flags, width, height, &lt;span style=&quot;color: #0000dd;&quot;&gt;32&lt;/span&gt;, Rmask, Gmask, Bmask, Amask&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;;
&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#125;&lt;/span&gt;
&amp;nbsp;
&lt;span style=&quot;color: #ff0000; font-style: italic;&quot;&gt;/* Fonctions de conversion entre SDL_Surface et QImage
   SDLSurfaceToQImage **DOIT** recevoir une surface
   construite avec createQImageCompliantSurface
*/&lt;/span&gt;
QImage SDLSurfaceToQImage&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;SDL_Surface *s&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;
&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#123;&lt;/span&gt;
	SDL_LockSurface&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;s&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;;
		QImage im&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;static_cast&amp;lt;uchar*&amp;gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;s-&amp;gt;pixels&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;, s-&amp;gt;w, s-&amp;gt;h, QImage::&lt;span style=&quot;color: #00eeff;&quot;&gt;Format_RGB32&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;;
        SDL_UnlockSurface&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;s&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;;
&amp;nbsp;
	&lt;span style=&quot;color: #0000ff;&quot;&gt;return&lt;/span&gt; im;
&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/pre&gt;

&lt;p&gt;2 améliorations conseillées:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;il est intéressant de définir notre propre type encapsulant ceci afin de réduire à 0 le risque de passer une mauvaise surface.&lt;/li&gt;
&lt;li&gt;on peut ajouter une méthode SDLSurfaceToQImage prenant en paramètre une référence vers un QImage afin de modifier les données d'un QImage précédemment créé. Dans les scènes requierant un affichage rapide, cela peut apporter une différence&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;&lt;br /&gt;
Nous avons donc un système SDL fonctionnel pour l'appli ainsi que la possibilité d'avoir des surfaces dont la transformation en QImage est extrêmement rapide (puisqu'il s'agit de la copie brute des octets formant la surface). A la différence de la première partie du tutoriel, nous ne dessinons plus sur une surface affichée à l'écran (que nous utilisions ou non le double buffering ne change rien). Il va donc nous falloir surcharger &lt;a href=&quot;http://doc.trolltech.com/4.4/qwidget.html#paintEvent&quot;&gt;paintEvent&lt;/a&gt; pour gérer l'affichage. La mise à jour de notre QImage se fera à chaque mise à jour de la surface. Inutile de le faire dans le paintEvent puisque certains de ces événements seront générés par le système sans qu'il y ait obligatoirement eu de modifications de la surface, par exemple le fait que le widget soit minimisé puis restauré/maximisé.&lt;/p&gt;

&lt;pre class=&quot;cpp&quot;&gt;&lt;span style=&quot;color: #0000ff;&quot;&gt;class&lt;/span&gt; Widget : &lt;span style=&quot;color: #0000ff;&quot;&gt;public&lt;/span&gt; QWidget
&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#123;&lt;/span&gt;
&lt;span style=&quot;color: #0000ff;&quot;&gt;protected&lt;/span&gt;:
   &lt;span style=&quot;color: #0000ff;&quot;&gt;virtual&lt;/span&gt; &lt;span style=&quot;color: #0000ff;&quot;&gt;void&lt;/span&gt; paintEvent&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;QPaintEvent *e&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;
   &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#123;&lt;/span&gt;
      QPainter p&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0000dd;&quot;&gt;this&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;;
      p.&lt;span style=&quot;color: #00eeff;&quot;&gt;drawImage&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;displayBuffer&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;;
   &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#125;&lt;/span&gt;
&amp;nbsp;
   &lt;span style=&quot;color: #0000ff;&quot;&gt;void&lt;/span&gt; modificationSurfaceSDL&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;
   &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#123;&lt;/span&gt;
      &lt;span style=&quot;color: #ff0000; font-style: italic;&quot;&gt;/* on modifie la surface renderer par diverses opérations de dessin */&lt;/span&gt;
      displayBuffer = SDLSurfaceToQImage&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;renderer&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;;
      update&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#41;&lt;/span&gt;; &lt;span style=&quot;color: #ff0000;&quot;&gt;// on demande par la même occasion un rafraichissement du widget&lt;/span&gt;
   &lt;span style=&quot;color: #000000;&quot;&gt;&amp;#125;&lt;/span&gt;
&amp;nbsp;
&lt;span style=&quot;color: #0000ff;&quot;&gt;private&lt;/span&gt;:
   SDL_Surface *renderer;
   QImage displayBuffer;
&lt;span style=&quot;color: #000000;&quot;&gt;&amp;#125;&lt;/span&gt;;&lt;/pre&gt;


&lt;p&gt;Voici le screenshot obligatoire présentant l'exemple en cours d'exécution:
&lt;a href=&quot;http://doc.qtfr.org/public/2006/sdl_adv.png&quot;&gt;&lt;img src=&quot;http://doc.qtfr.org/public/2006/.sdl_adv_m.jpg&quot; alt=&quot;Illustration SDL multi-widget&quot; style=&quot;display:block; margin:0 auto;&quot; /&gt;&lt;/a&gt;&lt;/p&gt;</description>
    
          <enclosure url="http://doc.qtfr.org/public/2006/sdl_qt.tar.gz"
      length="2169" type="application/x-gzip" />
          <enclosure url="http://doc.qtfr.org/public/2006/sdl_adv.tar.gz"
      length="3667" type="application/x-gzip" />
    
    
          <comments>http://doc.qtfr.org/post/2007/02/21/Integration-de-SDL#comment-form</comments>
      <wfw:comment>http://doc.qtfr.org/post/2007/02/21/Integration-de-SDL#comment-form</wfw:comment>
      <wfw:commentRss>http://doc.qtfr.org/feed/rss2/comments/50</wfw:commentRss>
      </item>
    
  <item>
    <title>Tutoriel Indépendant de Qt3</title>
    <link>http://doc.qtfr.org/post/2007/02/19/Tutoriel-Independant-de-Qt3</link>
    <guid isPermaLink="false">urn:md5:55dd7a0f08020297987a276cbbb17429</guid>
    <pubDate>Mon, 19 Feb 2007 22:09:00 +0100</pubDate>
    <dc:creator>Visiteur</dc:creator>
        <category>Tutoriels</category>
        <category>livre</category><category>version_Qt3</category>    
    <description>&lt;p&gt;Le tutoriel indépendant de Qt est un livre en ligne visant à couvrir la plupart des matières impliquées dans le processus de développement des applications professionnelles Qt de qualité.&lt;/p&gt;


&lt;p&gt;&lt;strong&gt;Version&lt;/strong&gt;&amp;nbsp;: Qt3&lt;br /&gt;
&lt;strong&gt;Auteur&lt;/strong&gt;&amp;nbsp;: e8johan, traduction Jean-Luc Biord (&lt;a href=&quot;http://forum.qtfr.org/profile.php?id=798&quot;&gt;jlbrd&lt;/a&gt;)&lt;/p&gt;    &lt;p&gt;Le tutoriel indépendant est disponible sur cette page&amp;nbsp;: &lt;a href=&quot;http://www.digitalfanatics.org/projects/qt_tutorial/fr/index.html&quot; hreflang=&quot;fr&quot;&gt;Tutoriel indépandant de Qt&lt;/a&gt;.&lt;/p&gt;


&lt;p&gt;Ce tutoriel a été écrit pour le programmeur C++ pour qui Qt est assez nouveau. Il couvre tous les aspects de la programmation Qt pour le débutant&amp;nbsp;:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Qt, couplage faible et programmation évènementielle&lt;/li&gt;
&lt;li&gt;Le Modèle Objet de Qt&lt;/li&gt;
&lt;li&gt;Ressources de Qt sur l’Internet&lt;/li&gt;
&lt;li&gt;Les Outils de Qt&lt;/li&gt;
&lt;li&gt;Une Application de base de Qt&lt;/li&gt;
&lt;li&gt;Une application Qt faite à la main.&lt;/li&gt;
&lt;li&gt;Le Carnet d’adresses&lt;/li&gt;
&lt;li&gt;Fichiers, répertoires et flux.&lt;/li&gt;
&lt;li&gt;XML&lt;/li&gt;
&lt;li&gt;Validation de saisie&lt;/li&gt;
&lt;li&gt;Qwt&lt;/li&gt;
&lt;li&gt;Le Canvas&lt;/li&gt;
&lt;li&gt;Listes, Arbres et Tableaux&lt;/li&gt;
&lt;li&gt;OpenGL&lt;/li&gt;
&lt;/ol&gt;</description>
    
    
    
          <comments>http://doc.qtfr.org/post/2007/02/19/Tutoriel-Independant-de-Qt3#comment-form</comments>
      <wfw:comment>http://doc.qtfr.org/post/2007/02/19/Tutoriel-Independant-de-Qt3#comment-form</wfw:comment>
      <wfw:commentRss>http://doc.qtfr.org/feed/rss2/comments/47</wfw:commentRss>
      </item>
    
  <item>
    <title>Débuter avec Qt 3</title>
    <link>http://doc.qtfr.org/post/2007/02/18/Debuter-avec-Qt-3</link>
    <guid isPermaLink="false">urn:md5:7275582d6400a22117d1b290597a2e67</guid>
    <pubDate>Sun, 18 Feb 2007 22:39:00 +0100</pubDate>
    <dc:creator>Nicolas</dc:creator>
        <category>Livres</category>
        <category>livre</category><category>version_Qt3</category>    
    <description>&lt;p&gt;Le seul ouvrage français traitant de Qt3, ce livre offre au débutant une introduction à Qt3.&lt;/p&gt;


&lt;p&gt;Il est disponible en &lt;strong&gt;libre téléchargement en PDF&lt;/strong&gt; sur ce site.&lt;/p&gt;    &lt;p&gt;&lt;img src=&quot;http://doc.qtfr.org/public/livres/debuter-qt3.jpg&quot; alt=&quot;debuter-qt3.jpg&quot; style=&quot;float:right; margin: 0 0 1em 1em;&quot; /&gt;&lt;/p&gt;

&lt;h3&gt;Informations&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;em&gt;Auteurs&lt;/em&gt;&amp;nbsp;: Jean-Luc Biord&lt;/li&gt;
&lt;li&gt;&lt;em&gt;Langue&lt;/em&gt;&amp;nbsp;: français&lt;/li&gt;
&lt;li&gt;&lt;em&gt;ISBN&lt;/em&gt;&amp;nbsp;:  295228430X&lt;/li&gt;
&lt;li&gt;&lt;em&gt;Pages&lt;/em&gt;&amp;nbsp;: 171&lt;/li&gt;
&lt;/ul&gt;


&lt;h3&gt;Résumé&lt;/h3&gt;


&lt;p&gt;Le premier livre français traitant de Qt3, ce livre permet au débutant de comprendre les mécanismes de la programmation Qt.&lt;/p&gt;


&lt;p&gt;Le livre n'est plus édité, par contre son auteur à décider de le laisser en &lt;strong&gt;libre téléchargement en PDF&lt;/strong&gt;&amp;nbsp;: &lt;a href=&quot;http://doc.qtfr.org/public/livres/debuter-qt3.pdf&quot;&gt;téléchargez&lt;/a&gt;.&lt;/p&gt;



&lt;h3&gt;Table des matières&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Pour commencer
&lt;ul&gt;
&lt;li&gt;Les outils fournis par Qt&lt;/li&gt;
&lt;li&gt;Un premier programme&lt;/li&gt;
&lt;li&gt;Gestion des objets en mémoire&lt;/li&gt;
&lt;li&gt;Signaux et Slots&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;ul&gt;
&lt;li&gt;Dialogues
&lt;ul&gt;
&lt;li&gt;Sous-classer QDialog&lt;/li&gt;
&lt;li&gt;Communication entre dialogues&lt;/li&gt;
&lt;li&gt;QFileDialog&lt;/li&gt;
&lt;li&gt;QMessageBox&lt;/li&gt;
&lt;li&gt;QInputDialog&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;ul&gt;
&lt;li&gt;Les principaux Widgets
&lt;ul&gt;
&lt;li&gt;QPushButton&lt;/li&gt;
&lt;li&gt;QRadioButton&lt;/li&gt;
&lt;li&gt;QCheckBox&lt;/li&gt;
&lt;li&gt;QButtonGroup&lt;/li&gt;
&lt;li&gt;QListBox&lt;/li&gt;
&lt;li&gt;QLineEdit&lt;/li&gt;
&lt;li&gt;QSpinBox&lt;/li&gt;
&lt;li&gt;QTextEdit&lt;/li&gt;
&lt;li&gt;QComboBox&lt;/li&gt;
&lt;li&gt;QLabel&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;ul&gt;
&lt;li&gt;Disposer les widgets dans les dialogues
&lt;ul&gt;
&lt;li&gt;Coordonnées absolues&lt;/li&gt;
&lt;li&gt;Position avec les layouts&lt;/li&gt;
&lt;li&gt;Fenêtres principales.&lt;/li&gt;
&lt;li&gt;Sous-classer QMainWindow&lt;/li&gt;
&lt;li&gt;Création des actions&lt;/li&gt;
&lt;li&gt;Menu et barres d’outils&lt;/li&gt;
&lt;li&gt;Barre de statut&lt;/li&gt;
&lt;li&gt;Ouvrir des dialogues&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;ul&gt;
&lt;li&gt;Les Entrées/Sorties
&lt;ul&gt;
&lt;li&gt;Fichiers&lt;/li&gt;
&lt;li&gt;Flux de données&lt;/li&gt;
&lt;li&gt;Utiliser ensemble Fichiers et Flux de données&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;ul&gt;
&lt;li&gt;Quelques classes intéressantes
&lt;ul&gt;
&lt;li&gt;QString&lt;/li&gt;
&lt;li&gt;Les modèles de classes&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;ul&gt;
&lt;li&gt;Utiliser Qt Designer
&lt;ul&gt;
&lt;li&gt;Création et gestion de projets&lt;/li&gt;
&lt;li&gt;Dialogues&lt;/li&gt;
&lt;li&gt;Fenêtres principales&lt;/li&gt;
&lt;li&gt;Collection d’images&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;ul&gt;
&lt;li&gt;Techniques de débogage&lt;/li&gt;
&lt;/ul&gt;</description>
    
          <enclosure url="http://doc.qtfr.org/public/livres/debuter-qt3.pdf"
      length="1726882" type="application/pdf" />
    
    
          <comments>http://doc.qtfr.org/post/2007/02/18/Debuter-avec-Qt-3#comment-form</comments>
      <wfw:comment>http://doc.qtfr.org/post/2007/02/18/Debuter-avec-Qt-3#comment-form</wfw:comment>
      <wfw:commentRss>http://doc.qtfr.org/feed/rss2/comments/45</wfw:commentRss>
      </item>
    
  <item>
    <title>C++ GUI Programming with Qt 3</title>
    <link>http://doc.qtfr.org/post/2007/02/18/C-GUI-Programming-with-Qt-3</link>
    <guid isPermaLink="false">urn:md5:1077ea1a3e8666df8b902d5401ba020a</guid>
    <pubDate>Sun, 18 Feb 2007 22:08:00 +0100</pubDate>
    <dc:creator>Nicolas</dc:creator>
        <category>Livres</category>
        <category>livre</category><category>version_Qt3</category>    
    <description>&lt;p&gt;Le premier livre officiel de Trolltech pour la programmation Qt (version 3.2). Il aborde tous les aspects de la bibliothèque&amp;nbsp;: organisation des widgets, évènements, programmation 2D et 3D...&lt;/p&gt;


&lt;p&gt;Il est actuellement en &lt;strong&gt;libre téléchargement en PDF&lt;/strong&gt; sur le site de l'éditeur.&lt;/p&gt;    &lt;p&gt;&lt;a href=&quot;http://www.phptr.com/bookstore/product.asp?isbn=0131240722&amp;amp;rl=1&quot;&gt;&lt;img src=&quot;http://doc.qtfr.org/public/livres/programming-qt3.jpg&quot; alt=&quot;programming-qt3.jpg&quot; style=&quot;float:right; margin: 0 0 1em 1em;&quot; /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;Informations&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;em&gt;Auteurs&lt;/em&gt;&amp;nbsp;: Jasmin Blanchette et Mark Summerfield&lt;/li&gt;
&lt;li&gt;&lt;em&gt;Editeur&lt;/em&gt;&amp;nbsp;: &lt;a href=&quot;http://vig.prenhall.com/&quot; hreflang=&quot;en&quot;&gt;Prentice Hall PTR&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;em&gt;Collection&lt;/em&gt;&amp;nbsp;: &lt;a href=&quot;http://www.phptr.com/bookstore/product.asp?isbn=0131240722&amp;amp;rl=1&quot; hreflang=&quot;en&quot;&gt;Bruce Perens' Open Source Series&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;em&gt;Langue&lt;/em&gt;&amp;nbsp;: anglais&lt;/li&gt;
&lt;li&gt;&lt;em&gt;ISBN&lt;/em&gt;&amp;nbsp;: 0131240722&lt;/li&gt;
&lt;li&gt;&lt;em&gt;Pages&lt;/em&gt;&amp;nbsp;: 464&lt;/li&gt;
&lt;/ul&gt;


&lt;h3&gt;Résumé&lt;/h3&gt;


&lt;p&gt;Le premier &lt;strong&gt;livre officiel de Trolltech&lt;/strong&gt; pour la programmation Qt (version 3.2).&lt;/p&gt;


&lt;p&gt;Ce livre couvre tous les aspects de la programmation Qt, avec une première partie offrant une approche simple pour le débutant, en détaillant pas à pas la création d'une application complète. La seconde partie détaille les différents aspects de la bibliothèque&amp;nbsp;: organisation des widgets, évènements, programmation 2D et 3D...&lt;/p&gt;


&lt;p&gt;Le CD comporte une version non-commerciale de Qt 3.2 pour Windows ainsi que les éditions GPL de Qt 3.2 sous Unix/Linux/Mac OSX.&lt;/p&gt;


&lt;p&gt;Le livre est actuellement en &lt;strong&gt;libre téléchargement en PDF&lt;/strong&gt; sur le site de &lt;a href=&quot;http://www.phptr.com/bookstore/product.asp?isbn=0131240722&amp;amp;rl=1#info3&quot; hreflang=&quot;en&quot;&gt;Prentice Hall&lt;/a&gt;.&lt;/p&gt;



&lt;h3&gt;Table des matières&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Basic Qt
&lt;ul&gt;
&lt;li&gt;Getting Started.&lt;/li&gt;
&lt;li&gt;Creating Dialogs.&lt;/li&gt;
&lt;li&gt;Creating Main Windows.&lt;/li&gt;
&lt;li&gt;Implementing Application Functionality.&lt;/li&gt;
&lt;li&gt;Creating Custom Widgets.&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;ul&gt;
&lt;li&gt;Intermediate Qt
&lt;ul&gt;
&lt;li&gt;Layout Management.&lt;/li&gt;
&lt;li&gt;Event Processing.&lt;/li&gt;
&lt;li&gt;2D and 3D Graphics.&lt;/li&gt;
&lt;li&gt;Drag and Drop.&lt;/li&gt;
&lt;li&gt;Input/Output.&lt;/li&gt;
&lt;li&gt;Container Classes.&lt;/li&gt;
&lt;li&gt;Databases.&lt;/li&gt;
&lt;li&gt;Networking.&lt;/li&gt;
&lt;li&gt;XML.&lt;/li&gt;
&lt;li&gt;Internationalization.&lt;/li&gt;
&lt;li&gt;Providing Online Help.&lt;/li&gt;
&lt;li&gt;Multithreading.&lt;/li&gt;
&lt;li&gt;Platform-Specific Features.&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;ul&gt;
&lt;li&gt;Appendices
&lt;ul&gt;
&lt;li&gt;Installing Qt.&lt;/li&gt;
&lt;li&gt;Qt's Class Hierarchy.&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;/ul&gt;</description>
    
    
    
          <comments>http://doc.qtfr.org/post/2007/02/18/C-GUI-Programming-with-Qt-3#comment-form</comments>
      <wfw:comment>http://doc.qtfr.org/post/2007/02/18/C-GUI-Programming-with-Qt-3#comment-form</wfw:comment>
      <wfw:commentRss>http://doc.qtfr.org/feed/rss2/comments/44</wfw:commentRss>
      </item>
    
</channel>
</rss>