<?xml version="1.0" encoding="ISO-8859-1"?>

<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/">
	<channel>
		<title>Forum du club des développeurs et IT Pro - Blogs - Jiyuu</title>
		<link>https://www.developpez.net/forums/blogs/135545-jiyuu/</link>
		<description>Developpez.com, le Club des Développeurs et IT Pro</description>
		<language>fr</language>
		<lastBuildDate>Fri, 24 Apr 2026 18:00:54 GMT</lastBuildDate>
		<generator>vBulletin</generator>
		<ttl>15</ttl>
		<image>
			<url>https://forum.developpez.be/images/misc/rss.jpg</url>
			<title>Forum du club des développeurs et IT Pro - Blogs - Jiyuu</title>
			<link>https://www.developpez.net/forums/blogs/135545-jiyuu/</link>
		</image>
		<item>
			<title><![CDATA[Mise en production d'un site Django, en utilisant Nginx et Gunicorn]]></title>
			<link>https://www.developpez.net/forums/blogs/135545-jiyuu/b47/mise-production-d-site-django-utilisant-nginx-gunicorn/</link>
			<pubDate>Sun, 17 Jan 2016 19:27:41 GMT</pubDate>
			<description>### toujours en mode...</description>
			<content:encoded><![CDATA[<blockquote class="blogcontent restore">### toujours en mode ébauche... n'hésitez pas à me faire toutes les remarques utiles nécessaires.<br />
<br />
Bonjour à tous,<br />
<br />
Pré-requis (à par connaitre Python &amp; Django) :<br />
<ul><li style="">connaitre SSH ;</li><li style="">être habitué aux OS basés sur linux ;</li><li style="">avoir un serveur permettant d'utiliser Python, Django et SSH ;</li><li style="">si possible avoir un serveur de production aussi à jour que le poste servant de serveur de développement. </li></ul><br />
<br />
Après la création de votre site web avec Django, vous allez rapidement avoir besoin de mettre en production celui-ci. Pour rappel, <b>IL NE FAUT SURTOUT PAS</b> utiliser le serveur de développement fourni avec Django pour travailler en production. Il existe sur le marché plusieurs hébergeurs permettant de faire ceci, mais nous allons étudier ici la manière de faire sans passer par ces hébergeurs. Nous allons donc créer notre propre serveur de production.<br />
<br />
Dans ce billet nous allons découvrir le paramétrage le plus simple pour faire fonctionner un site Django sur un serveur privé. Plusieurs fournisseurs offrent ce type de service. La seule chose que je conseille c'est de veiller à avoir un serveur de production aussi à jour que notre serveur de développement. Pour ma part je suis parti sur un serveur Archlinux.<br />
<br />
<br />
<font size="3"><div style="text-align: center;"><b>Passons aux choses sérieuses</b></div></font><br />
Nous allons utiliser Gunicorn et Nginx. Je vous invite donc à les installer si ce n'est pas déjà fait. Évidemment il est possible d'utiliser d'autres outils comme mod_wsgi et Apache. À l'heure actuelle, l'objet de ce billet n'est pas d'expliquer en profondeur l'utilité de l'un ou l'autre. Si besoin je vous invite à feuilleter les tutoriels disponibles sur  <br />
Une fois l'installation faite vous pouvez vérifier que Nginx fonctionne correctement en vous rendant sur l'adresse localhost depuis votre navigateur web.<br />
<i><br />
Note : Gunicorn est l'outil (serveur) qui nous permettra de mettre en production notre site Django. Malheureusement celui-ci ne sait pas gérer les fichiers statiques, comprenez par là vos images, *.css, *.js, ... Pour cela il nous allons utiliser Nginx.</i><br />
<br />
<b><u>Ok, mais comment j'utilise tout ça ?</u></b><br />
Théoriquement Nginx est livré avec une configuration de base assez simple, que vous trouverez dans le fichier /etc/nginx/nginx.conf (chemin à adapter éventuellement selon votre OS). C'est elle qui permet l'affichage de <b><i>localhost</i></b>. La première chose à faire est d'ajouter, le cas échéant, à la fin de nginx.conf la ligne suivante :<br />
<div class="bbcode_container">
	<table width="100%" border="0" cellspacing="0" cellpadding="0"><tr>
	<td style="border: 0; padding: 0; text-align: left">Code  :</td>
	<td style="border: 0; padding: 0; text-align: right"><a href="#" onclick="return ano_selectionnerCode(this);">Sélectionner tout</a> -
	<a href="#" onclick="return ano_etendreCode(this);">Visualiser dans une fenêtre à part</a></td></tr></table>
	<pre class="bbcode_code" style="height:36px;">include /etc/nginx/sites-enabled/*;</pre>
</div>Par la suite, l'idée est de créer des sous-configurations et de les activer au besoin. Pour cela, la méthode habituellement utilisé est de créer les deux dossiers <b>sites-available</b> et <b>sites-enabled</b> directement dans <b>/etc/nginx</b>. On va donc demander au fichier de configuration d'inclure aussi ce qui se trouve dans sites-enabled. <br />
Donc si vous avez bien suivi :<br />
<ul><li style="">sites-available : sites créés &amp; disponibles</li><li style="">sites-enabled : sites en fonction. </li></ul><br />
La première étape est de configurer correctement votre projet afin de servir les fichiers statiques. Pour cela, je vous invite à vous référer à la <a href="https://docs.djangoproject.com/fr/1.9/howto/static-files/" target="_blank">documentation officielle</a> qui explique bien les différents nuances des paramètres présents dans votre settings.py.<br />
<br />
Une fois settings.py correctement configuré, il faut passer à la configuration de Nginx. Pour rappel, le but ici n'est pas de s'étendre sur cet outil, mais de proposer une solution simple pour installer notre site web. En ayant enlevé toutes les lignes commentées et en allant au plus simple, dans mon cas, nginx.conf correspond à ceci :<br />
<div class="bbcode_container">
	<table width="100%" border="0" cellspacing="0" cellpadding="0"><tr>
	<td style="border: 0; padding: 0; text-align: left">Code  :</td>
	<td style="border: 0; padding: 0; text-align: right"><a href="#" onclick="return ano_selectionnerCode(this);">Sélectionner tout</a> -
	<a href="#" onclick="return ano_etendreCode(this);">Visualiser dans une fenêtre à part</a></td></tr></table>
	<pre class="bbcode_code" style="height:204px;"><table cellspacing="0" cellpadding="0"><tr><td valign="top" width="33"><div style="border: 1px dashed gray; padding-left: 5px; padding-right: 5px; margin-right: 5px; text-align: right; font-family: monospace">1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br /></div></td><td valign="top"><pre style="margin: 0">
user root;   #pour dire qui a le droit d'utiliser le script
worker_processes  1;

events {
    worker_connections  1024;
}

http {
    include       mime.types;
    default_type  application/octet-stream;

    sendfile        on;
    keepalive_timeout  65;

    include /etc/nginx/conf.d/*.conf;
    include /etc/nginx/sites-enabled/*; #pour inclure mes fichiers de configuration propres à chacun de mes sites.
}</pre></td></tr></table></pre>
</div>Dans un second temps, nous allons créer un fichier de configuration propre à notre site (le nom importe peu) dans sites-available. Voici un exemple basique : <br />
<div class="bbcode_container">
	<table width="100%" border="0" cellspacing="0" cellpadding="0"><tr>
	<td style="border: 0; padding: 0; text-align: left">Code  :</td>
	<td style="border: 0; padding: 0; text-align: right"><a href="#" onclick="return ano_selectionnerCode(this);">Sélectionner tout</a> -
	<a href="#" onclick="return ano_etendreCode(this);">Visualiser dans une fenêtre à part</a></td></tr></table>
	<pre class="bbcode_code" style="height:204px;"><table cellspacing="0" cellpadding="0"><tr><td valign="top" width="33"><div style="border: 1px dashed gray; padding-left: 5px; padding-right: 5px; margin-right: 5px; text-align: right; font-family: monospace">1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br /></div></td><td valign="top"><pre style="margin: 0">server {
    listen 80;
    server_name monsupersite.fr *.monsupersite.fr; #mettez ici tous les liens devant pointer vers votre site

location / {
               proxy_pass http://127.0.0.1:8000/;
               proxy_read_timeout 300;
               proxy_redirect off;
               proxy_buffering off;
               proxy_store off;
               proxy_set_header Host $host;
               proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
     }
 
     location /static/ {
                alias /home/monuser/www/staticFiles/; #le dossier /home/monuser/www correspond au dossier dans lequel vous aurez mis votre projet, c'est à dire tout ce qui se trouve au même niveau que manage.py
           }
}</pre></td></tr></table></pre>
</div>N'oubliez pas de créer un lien symbolique de ce ficher vers <b>sites-enabled</b> afin de le rendre actif.<br />
<br />
Une fois ceci fait, rendez-vous au même niveau que manage.py et lancez les commandes suivantes (à adapter selon votre projet et votre OS) :<br />
<div class="bbcode_container">
	<table width="100%" border="0" cellspacing="0" cellpadding="0"><tr>
	<td style="border: 0; padding: 0; text-align: left">Code  :</td>
	<td style="border: 0; padding: 0; text-align: right"><a href="#" onclick="return ano_selectionnerCode(this);">Sélectionner tout</a> -
	<a href="#" onclick="return ano_etendreCode(this);">Visualiser dans une fenêtre à part</a></td></tr></table>
	<pre class="bbcode_code" style="height:60px;"><table cellspacing="0" cellpadding="0"><tr><td valign="top" width="26"><div style="border: 1px dashed gray; padding-left: 5px; padding-right: 5px; margin-right: 5px; text-align: right; font-family: monospace">1<br />2<br /></div></td><td valign="top"><pre style="margin: 0">sudo /etc/init.d/nginx restart
gunicorn jiyuu.wsgi:application --bind=127.0.0.1:8000 --daemon</pre></td></tr></table></pre>
</div><i>jiyuu.wsgi:application : voir settings.py pour adapter cet argument</i>.<br />
<br />
Note : on voit ici que l'on demande à gunicorn de lancer le serveur sur le port 127.0.0.1:8000, ce qui correspond à notre configuration dans le fichier sites-available. Vous aurez compris qu'il est ainsi possible de mettre en place plusieurs site web sur le même VPS.</blockquote>

]]></content:encoded>
			<dc:creator>Jiyuu</dc:creator>
			<guid isPermaLink="true">https://www.developpez.net/forums/blogs/135545-jiyuu/b47/mise-production-d-site-django-utilisant-nginx-gunicorn/</guid>
		</item>
		<item>
			<title>PySide : le binding LGPL Python pour Qt est de retour</title>
			<link>https://www.developpez.net/forums/blogs/135545-jiyuu/b889/pyside-binding-lgpl-python-qt-retour/</link>
			<pubDate>Thu, 19 Nov 2015 07:13:23 GMT</pubDate>
			<description><![CDATA[En début d'année, Digia avait...]]></description>
			<content:encoded><![CDATA[<blockquote class="blogcontent restore">En début d'année, Digia avait annoncé l'<a href="http://pyqt.developpez.com/actu/80721/Le-projet-PySide-est-declare-abandonne-en-2015-il-ne-reste-plus-que-PyQt-comme-binding-Python-de-Qt/" target="_blank">arrêt du projet PySide</a>, le deuxième binding Python pour Qt qui se distinguait essentiellement du binding historique, <a href="https://riverbankcomputing.com/software/pyqt/intro" target="_blank">PyQt</a>, par la licence utilisée. En effet, PySide offrait la possibilité de développer des applications sous la licence LGPL alors que PyQt ne propose &quot;que&quot; la GPL ou une licence commerciale.<br />
<br />
Le projet avait été initié par Nokia pour sa plateforme MeeGo, qui a mené à <a href="http://pyqt.developpez.com/actu/36457/PySide-le-binding-Python-de-Qt-en-danger-suite-a-l-arret-des-subsides-de-Nokia/" target="_blank">l'arrêt du financement du projet</a> et petit à petit des contributions. Plus récemment, <a href="http://www.developpez.net/forums/showthread.php?t=1495870#post8113789" target="_blank">il a été marqué officiellement abandonné</a> à cause de l'absence de contributeurs au projet, les versions ayant du mal à suivre l'évolution de Qt, en particulier le passage à Qt 5. <br />
<br />
Il semblerait cependant que depuis peu le projet renaisse… Pour preuve, le graphique suivant montre le nombre de commits sur le dépôt GitHub : les contributions étaient régulières jusqu'en 2012 et ont repris cette année. Il faut cependant remarquer qu'ils sont produits par <a href="https://github.com/PySide/pyside2/graphs/contributors?from=2015-05-28&amp;to=2015-11-19&amp;type=c" target="_blank">une seule et même personne</a>, en très grande majorité. <br />
<br />
<img src="http://tcuvelier.developpez.com/news/images/qt/pyside-2/activite-pyside.png" border="0" alt="" /><br />
<br />
Sur la page du <a href="http://wiki.qt.io/PySide" target="_blank">wiki Qt dédiée à PySide</a>, il n'est plus question de considérer PySide comme un projet mort, la version 1.2.4 étant même récemment sortie. Cependant, le binding reste basé sur Qt 4.8. Là encore, une surprise attend les développeurs Python souhaitant utiliser le framework Qt : effectivement, <a href="https://github.com/PySide/pyside2" target="_blank">une version 2 de PySide</a> a vu les premiers développements en juin et celle-ci se base sur Qt 5.<br />
<br />
Nul doute, ceci va intéresser nos membres et nous ne manquerons pas de vous informer sur l'évolution de cette version.<br />
<br />
Corédigé avec <a href="http://www.developpez.net/forums/u254882/dourouc05/" target="_blank">Thibaut Cuvelier</a>. <br />
<br />
<b>Et vous ?</b><br />
:arrow: Le retour de PySide est-il une bonne nouvelle ?<br />
:arrow: Bien qu'il ait peu évolué ces derniers temps, l'utilisiez-vous toujours ?</blockquote>

]]></content:encoded>
			<dc:creator>Jiyuu</dc:creator>
			<guid isPermaLink="true">https://www.developpez.net/forums/blogs/135545-jiyuu/b889/pyside-binding-lgpl-python-qt-retour/</guid>
		</item>
		<item>
			<title>Sortie de KD Reports 1.7, maintenant compilable avec CMake, avec une classe PreviewDialog plus complète</title>
			<link>https://www.developpez.net/forums/blogs/135545-jiyuu/b858/sortie-kd-reports-1-7-compilable-cmake-classe-previewdialog-plus-complete/</link>
			<pubDate>Sat, 31 Oct 2015 09:37:15 GMT</pubDate>
			<description><![CDATA[KDAB vient d'annoncer la...]]></description>
			<content:encoded><![CDATA[<blockquote class="blogcontent restore">KDAB vient d'annoncer la sortie de la dernière version de KDReports, sa bibliothèque Qt facilitant la création de documents PDF sous licence GPL ou LGPL. Elle permet, depuis un code C++ ou des fichiers XML, HTML ou CSV, de créer des rapports PDF en incluant des images, du texte ou des tableaux.<br />
<br />
L'une des premières nouveautés de cette nouvelle mouture 1.7 est l'arrivée d'une procédure de compilation utilisant CMake, décrite dans le fichier <a href="https://github.com/KDAB/KDReports/blob/master/INSTALL-cmake.txt" target="_blank">INSTALL-cmake.txt</a>.<br />
<br />
Du côté de l'API, cette version voit arriver l'élément Frame ; la méthode Report::setDocumentName() donne un nom à la tâche d'impression en cours et AutoTableElement::NonBreakableLinesRole interdit la césure à l'intérieur d'un mot dans une cellule de tableau.<br />
<br />
La classe PreviewDialog se voit aussi affectée par ce lot de nouveautés, avec un nouveau bouton « Save…» qui ouvre une boite de dialogue d'impression pour l'enregistrement du document au format PDF. KDAB a aussi ajouté les méthodes setDefaultSaveDirectory() et setDirectoryBrowsingEnabled() permettant respectivement d'indiquer le répertoire de sauvegarde par défaut et d'interdire ou non le choix à l'utilisateur du dossier de sauvegarde.<br />
<br />
À cette classe est aussi ajoutée la méthode setQuickPrinterName(QString) qui fait apparaître un nouveau bouton « Print with [printerName] » pour une impression rapide sans passer par la boite de dialogue.<br />
<br />
Dans le mode feuille de calcul (Spreadsheet), les développeurs de KDAB ont ajouté les fonctionnalités suivantes :<br />
<ul><li style="">fusions multiples de lignes et de colonnes ;</li><li style="">paramètres de taille, couleur de bordure et couleur d'arrière plan des entêtes ;</li><li style="">texte multiligne (le caractère \n est utilisé explicitement) ;</li><li style="">hauteurs fixes de lignes (voir Label en exemple). </li></ul><br />
 <br />
<b>Et vous ?</b><br />
:arrow: Connaissiez-vous KDReports ?<br />
:arrow: L'utilisez-vous ? Pourquoi ?</blockquote>

]]></content:encoded>
			<dc:creator>Jiyuu</dc:creator>
			<guid isPermaLink="true">https://www.developpez.net/forums/blogs/135545-jiyuu/b858/sortie-kd-reports-1-7-compilable-cmake-classe-previewdialog-plus-complete/</guid>
		</item>
		<item>
			<title>Utilisation des fichiers de configuration en QML, en se servant du composant Settings</title>
			<link>https://www.developpez.net/forums/blogs/135545-jiyuu/b828/utilisation-fichiers-configuration-qml-se-servant-composant-settings/</link>
			<pubDate>Tue, 20 Oct 2015 19:59:08 GMT</pubDate>
			<description>:salut: 
 
Le développement...</description>
			<content:encoded><![CDATA[<blockquote class="blogcontent restore">:salut:<br />
<br />
Le développement d'un programme ou d'une application nécessite parfois l'utilisation de fichiers de configuration. L'API de QML offre un composant permettant de faire ceci très simplement. Il s'agit de <a href="http://doc.qt.io/qt-5/qml-qt-labs-settings-settings.html" target="_blank">Settings</a>. Son utilisation est tellement simple qu'au début j'ai eu du mal à y croire. Je vous propose ici une petite présentation de celui-ci.<br />
<br />
<br />
Avant toute chose, commencez par créer un projet en C++ ou en Python lançant une application QML. Pour le bon déroulement de la lecture de ce billet, voici le code que j'utiliserai :<br />
<br />
<div class="bbcode_container">
	<table width="100%" border="0" cellspacing="0" cellpadding="0"><tr>
	<td style="border: 0; padding: 0; text-align: left">Code c++ :</td>
	<td style="border: 0; padding: 0; text-align: right"><a href="#" onclick="return ano_selectionnerCode(this);">Sélectionner tout</a> -
	<a href="#" onclick="return ano_etendreCode(this);">Visualiser dans une fenêtre à part</a></td></tr></table>
	<pre class="bbcode_code" style="height:204px;"><table cellspacing="0" cellpadding="0"><tr><td valign="top" width="33"><div style="border: 1px dashed gray; padding-left: 5px; padding-right: 5px; margin-right: 5px; text-align: right; font-family: monospace">1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br /></div></td><td valign="top"><pre style="margin: 0"><span style="color: #339933;">#include</span><span style="color: #FF0000;"> &lt;QGuiApplication&gt;</span>
<span style="color: #339933;">#include</span><span style="color: #FF0000;"> &lt;QQmlApplicationEngine&gt;</span>
&nbsp;
<span style="color: #0000ff;">int</span> main<span style="color: black;">&#40;</span><span style="color: #0000ff;">int</span> argc, <span style="color: #0000ff;">char</span> *argv<span style="color: black;">&#91;</span><span style="color: black;">&#93;</span><span style="color: black;">&#41;</span>
<span style="color: black;">&#123;</span>
    QGuiApplication app<span style="color: black;">&#40;</span>argc, argv<span style="color: black;">&#41;</span>;
    QQmlApplicationEngine engine;
&nbsp;
    app.setOrganizationName<span style="color: black;">&#40;</span><span style="color: #FF0000;">&quot;JiyuuOnDVP&quot;</span><span style="color: black;">&#41;</span>;
    app.setApplicationName<span style="color: black;">&#40;</span><span style="color: #FF0000;">&quot;TestSettings&quot;</span><span style="color: black;">&#41;</span>;
&nbsp;
    engine.load<span style="color: black;">&#40;</span>QUrl<span style="color: black;">&#40;</span>QStringLiteral<span style="color: black;">&#40;</span><span style="color: #FF0000;">&quot;qrc:/main.qml&quot;</span><span style="color: black;">&#41;</span><span style="color: black;">&#41;</span><span style="color: black;">&#41;</span>;
&nbsp;
    <span style="color: #0000ff;">return</span> app.exec<span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>;
<span style="color: black;">&#125;</span></pre></td></tr></table></pre>
</div><br />
Les lignes :<br />
<div class="bbcode_container">
	<table width="100%" border="0" cellspacing="0" cellpadding="0"><tr>
	<td style="border: 0; padding: 0; text-align: left">Code  :</td>
	<td style="border: 0; padding: 0; text-align: right"><a href="#" onclick="return ano_selectionnerCode(this);">Sélectionner tout</a> -
	<a href="#" onclick="return ano_etendreCode(this);">Visualiser dans une fenêtre à part</a></td></tr></table>
	<pre class="bbcode_code" style="height:60px;"><table cellspacing="0" cellpadding="0"><tr><td valign="top" width="26"><div style="border: 1px dashed gray; padding-left: 5px; padding-right: 5px; margin-right: 5px; text-align: right; font-family: monospace">1<br />2<br /></div></td><td valign="top"><pre style="margin: 0">app.setOrganizationName(&quot;JiyuuOnDVP&quot;);
app.setApplicationName(&quot;TestSettings&quot;);</pre></td></tr></table></pre>
</div>vont vous permettre de choisir l'emplacement et le nom de votre fichier de configuration.<br />
Ici, notre fichier portera le nom de TestSettings qui sera stocké dans le dossier JiyuuOnDVP lui-même présent dans le dossier de configuration par défaut de votre OS.<br />
Si comme moi vous utilisez un OS basé sur Linux avec KDE 5, ce dossier correspond au dossier <i>.config</i> de votre home<br />
<br />
<br />
Son équivalent Python<br />
<div class="bbcode_container">
	<table width="100%" border="0" cellspacing="0" cellpadding="0"><tr>
	<td style="border: 0; padding: 0; text-align: left">Code python :</td>
	<td style="border: 0; padding: 0; text-align: right"><a href="#" onclick="return ano_selectionnerCode(this);">Sélectionner tout</a> -
	<a href="#" onclick="return ano_etendreCode(this);">Visualiser dans une fenêtre à part</a></td></tr></table>
	<pre class="bbcode_code" style="height:204px;"><table cellspacing="0" cellpadding="0"><tr><td valign="top" width="33"><div style="border: 1px dashed gray; padding-left: 5px; padding-right: 5px; margin-right: 5px; text-align: right; font-family: monospace">1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br /></div></td><td valign="top"><pre style="margin: 0"><span style="color: #808080;">#!/usr/bin/env python</span>
<span style="color: #808080;"># -*- coding: utf-8 -*-</span>
&nbsp;
<span style="color: #0000ff;">import</span> sys, os
&nbsp;
<span style="color: #0000ff;">from</span> PyQt5.QtGui <span style="color: #0000ff;">import</span> QGuiApplication
<span style="color: #0000ff;">from</span> PyQt5.QtQml <span style="color: #0000ff;">import</span> QQmlApplicationEngine
&nbsp;
&nbsp;
<span style="color: #0000ff;">if</span> <span style="color: #0080ff;">__name__</span> == <span style="color: #FF0000;">'__main__'</span>:
&nbsp;
    app = QGuiApplication<span class="br0">&#40;</span>sys.argv<span class="br0">&#41;</span>
    engine = QQmlApplicationEngine<span class="br0">&#40;</span><span class="br0">&#41;</span>
&nbsp;
    app.setOrganizationName<span class="br0">&#40;</span><span style="color: #FF0000;">&quot;JiyuuOnDVP&quot;</span><span class="br0">&#41;</span>;
    app.setApplicationName<span class="br0">&#40;</span><span style="color: #FF0000;">&quot;TestSettings&quot;</span><span class="br0">&#41;</span>;
&nbsp;
&nbsp;
    context = engine.rootContext<span class="br0">&#40;</span><span class="br0">&#41;</span>
    engine.load<span class="br0">&#40;</span><span style="color: #FF0000;">'./main.qml'</span><span class="br0">&#41;</span>
    sys.exit<span class="br0">&#40;</span>app.exec_<span class="br0">&#40;</span><span class="br0">&#41;</span><span class="br0">&#41;</span></pre></td></tr></table></pre>
</div><br />
<br />
Rentrons maintenant dans le vif du sujet. Le code QML :<br />
<div class="bbcode_container">
	<table width="100%" border="0" cellspacing="0" cellpadding="0"><tr>
	<td style="border: 0; padding: 0; text-align: left">Code qml :</td>
	<td style="border: 0; padding: 0; text-align: right"><a href="#" onclick="return ano_selectionnerCode(this);">Sélectionner tout</a> -
	<a href="#" onclick="return ano_etendreCode(this);">Visualiser dans une fenêtre à part</a></td></tr></table>
	<pre class="bbcode_code" style="height:204px;"><table cellspacing="0" cellpadding="0"><tr><td valign="top" width="33"><div style="border: 1px dashed gray; padding-left: 5px; padding-right: 5px; margin-right: 5px; text-align: right; font-family: monospace">1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br /></div></td><td valign="top"><pre style="margin: 0"><span style="color: #0000ff;">import</span> QtQuick <span style="color: #cc66cc;">2.5</span>
<span style="color: #0000ff;">import</span> QtQuick.<span style="color: #0080ff;">Window</span> <span style="color: #cc66cc;">2.2</span>
<span style="color: #0000ff;">import</span> <span style="color: #0080ff;">Qt</span>.labs.settings <span style="color: #cc66cc;">1.0</span>
&nbsp;
<span style="color: #0080ff;">Window</span> <span style="color: black;">&#123;</span>
    <span style="color: #970009;">visible</span>: <span style="color: #339933;">true</span>
    <span style="color: #970009;">title</span>: qsTr<span style="color: black;">&#40;</span><span style="color: #FF0000;">'Test Settings'</span><span style="color: black;">&#41;</span>
&nbsp;
    <span style="color: #0080ff;">Settings</span> <span style="color: black;">&#123;</span>
        <span style="color: #970009;">category</span>: <span style="color: #FF0000;">&quot;Category_1&quot;</span>
&nbsp;
        <span style="color: #0000ff;">property</span> <span style="color: #0000ff;">string</span> <span style="color: #970009;">value1</span>: <span style="color: #FF0000;">&quot;ma premi&egrave;re entr&eacute;e&quot;</span>
&nbsp;
    <span style="color: black;">&#125;</span>
<span style="color: black;">&#125;</span></pre></td></tr></table></pre>
</div><br />
Et c'est tout ... quand je disais que c'était déconcertant de simplicité je ne mentais pas :mouarf:<br />
<br />
Cependant, prenons quelques instants pour expliquer ce qui se passe.<br />
<br />
Lorsque vous allez utiliser le composant Settings, celui-ci agira ni plus ni moins comme a un appel au fichier de configuration précédemment configuré (voire votre code C++ ou Python). Si ce fichier est vide ou s'il n'existe pas, le code QML va automatiquement le remplir ou le créer.<br />
Les deux seuls points importants à respecter : <ul><li style="">déclarer une seule propriété <i>category</i> par composant Settings créé ;</li><li style=""> ne pas déclarer deux fois la même propriété <i>category</i> dans le même projet.</li></ul><br />
<br />
Évidemment vous pouvez créer autant de composants Settings que vous le souhaitez.<br />
<br />
Bonne continuation à tous.<br />
<br />
<br />
J</blockquote>

]]></content:encoded>
			<dc:creator>Jiyuu</dc:creator>
			<guid isPermaLink="true">https://www.developpez.net/forums/blogs/135545-jiyuu/b828/utilisation-fichiers-configuration-qml-se-servant-composant-settings/</guid>
		</item>
		<item>
			<title>Créer un exécutable windows sur une installation Linux avec Qt Creator</title>
			<link>https://www.developpez.net/forums/blogs/135545-jiyuu/b797/creer-executable-windows-installation-linux-qt-creator/</link>
			<pubDate>Fri, 09 Oct 2015 21:14:13 GMT</pubDate>
			<description>Bonjour à tous, 
 
Si vous...</description>
			<content:encoded><![CDATA[<blockquote class="blogcontent restore">Bonjour à tous,<br />
<br />
Si vous développez vos programmes sous Linux, vous allez sûrement avoir besoin de le déployer sur Windows. Mais vous n'avez pas de machine équipée de cet OS et vous vous sentez bloqué. Rassurez vous, vous ne le serez pas longtemps. Dans les lignes qui suivent vous allez voir comment installer une version windows de Qt sur votre distribution Linux préférée et comment compiler correctement votre programme pour qu'il puisse être exécuté sur l'OS à la fenêtre ;).<br />
<br />
Il y a plusieurs moyens d'effectuer ceci. Ici nous allons voir comment faire en utilisant <a href="http://download.qt.io/official_releases/qt/5.5/5.5.0/qt-opensource-windows-x86-msvc2013_64-5.5.0.exe" target="_blank">Qt 5.5.0 for Windows 32-bit MinGW 4.9.2</a> pour une installation quasi &quot;ready to use&quot;. Seul point noir, vous ne pourrait pas créer un programme utilisant WebEngine :( ;<br />
 <br />
La première chose à faire est d'installer Wine, mono et gecko. Personnellement, j'ai configuré Wine pour fonctionner comme Win 8. Pour régler ceci vous pouvez utiliser la commande<div class="bbcode_container">
	<table width="100%" border="0" cellspacing="0" cellpadding="0"><tr>
	<td style="border: 0; padding: 0; text-align: left">Code  :</td>
	<td style="border: 0; padding: 0; text-align: right"><a href="#" onclick="return ano_selectionnerCode(this);">Sélectionner tout</a> -
	<a href="#" onclick="return ano_etendreCode(this);">Visualiser dans une fenêtre à part</a></td></tr></table>
	<pre class="bbcode_code" style="height:36px;">winecfg</pre>
</div>.<br />
<br />
Suivez les différents étapes jusqu'à la fin de l'installation. Pensez bien à installer Qt Creator.<br />
<br />
Ceci fait, ouvrez votre projet avec la version Qt Creator nouvellement installée et lancée la commande Execute (le raccourcis de base est Ctrl + R). Normalement votre application devrait ce lancer.<br />
Si vous rencontrez des problèmes à ce niveau, cela peut venir de la configuration de votre .pro ou de différents paramètres dans votre application. Je pense en particulier à des chemins codés en dur : bahh oui, windows aura énormément de mal à comprendre pourquoi vous lui demandez d'aller dans votre home :aie:.<br />
<br />
Si vous regardez le dossier généré vous devriez y voir votre exécutable. :P Attention cependant, ce n'est pas fini. Il va falloir maintenant inclure dans ce dossier les librairies nécessaires pour faire fonctionner votre programme de manière standalone. Pour cela les versions récentes de Qt offre un outil sympa : windeployqt. La capture d'écran qui suit montre comment l'utiliser: dans les grandes lignes, il suffit d'ajouter une étape à la compilation release (à priori vous n'allez pas distribuer une version debug de votre application) qui importera les librairies nécessaire au déploiement sur Windows (n'oubliez pas le <b>.</b> dans la zone <i>arguments</i>). À chaque fois que vous relancerez Execute depuis Qt Creator, les libraires nécessaires seront importées :<br />
<div style="text-align: center;"><img src="https://www.developpez.net/forums/attachments/p189838d1444424835/environnements-developpement/delphi/edi/kylix-indy-kylix-pb/3.png/" border="0" alt="Nom : 3.png
Affichages : 801
Taille : 10,4 Ko"  style="float: CONFIG" /></div><br />
Vois devriez à présent avoir un dossier release complet qui pourra être installé sur tout PC Windows récent.<br />
<br />
Note : windeployqt.exe semble oublier au moins 2 modules :<br />
<ul><li style="">Qt5Quick.dll ;</li><li style="">Qt5Sql.dll.</li></ul><br />
<br />
Il vous faudra les ajouter à la main. Vous les trouverez dans le dossier bin de mingw : chez moi ça ressemble à ceci : <i>Qt/Qt5.5.0/5.5/mingw492_32/bin/</i></blockquote>

]]></content:encoded>
			<dc:creator>Jiyuu</dc:creator>
			<guid isPermaLink="true">https://www.developpez.net/forums/blogs/135545-jiyuu/b797/creer-executable-windows-installation-linux-qt-creator/</guid>
		</item>
		<item>
			<title><![CDATA[Création dynamique d'une courbe en QML]]></title>
			<link>https://www.developpez.net/forums/blogs/135545-jiyuu/b792/creation-dynamique-d-courbe-qml/</link>
			<pubDate>Thu, 08 Oct 2015 07:37:20 GMT</pubDate>
			<description>Bonjour, 
 
Dans un précédent...</description>
			<content:encoded><![CDATA[<blockquote class="blogcontent restore">Bonjour,<br />
<br />
Dans un <a href="http://www.developpez.net/forums/blogs/135545-jiyuu/b143/creation-d-courbe-qml/" target="_blank">précédent billet</a>, nous avions vu comment créer une courbe en QML depuis une liste de points connus.<br />
<br />
Je vous propose maintenant de voir comment créer une courbe dynamiquement, c'est-à-dire en exploitant, par exemple, une liste de coordonnées depuis une base de données ou d'un calcul.<br />
<br />
En nous inspirant du premier billet, nous allons créer la fenêtre, le canvas et les différents éléments qui nous permettront de créer notre courbe ou d'interagir avec celle-ci.<br />
Voici ce que cela donnerait :<br />
<br />
<br />
<div class="bbcode_container">
	<table width="100%" border="0" cellspacing="0" cellpadding="0"><tr>
	<td style="border: 0; padding: 0; text-align: left">Code qml :</td>
	<td style="border: 0; padding: 0; text-align: right"><a href="#" onclick="return ano_selectionnerCode(this);">Sélectionner tout</a> -
	<a href="#" onclick="return ano_etendreCode(this);">Visualiser dans une fenêtre à part</a></td></tr></table>
	<pre class="bbcode_code" style="height:204px;"><table cellspacing="0" cellpadding="0"><tr><td valign="top" width="40"><div style="border: 1px dashed gray; padding-left: 5px; padding-right: 5px; margin-right: 5px; text-align: right; font-family: monospace">1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br />22<br />23<br />24<br />25<br />26<br />27<br />28<br />29<br />30<br />31<br />32<br />33<br />34<br />35<br />36<br />37<br />38<br />39<br />40<br />41<br />42<br />43<br />44<br />45<br />46<br />47<br />48<br />49<br />50<br />51<br />52<br />53<br />54<br />55<br />56<br />57<br />58<br />59<br />60<br />61<br />62<br />63<br />64<br />65<br />66<br />67<br />68<br />69<br />70<br />71<br />72<br />73<br />74<br />75<br />76<br />77<br />78<br />79<br />80<br />81<br />82<br />83<br />84<br />85<br />86<br />87<br />88<br />89<br />90<br />91<br />92<br />93<br />94<br />95<br />96<br />97<br />98<br />99<br />100<br />101<br />102<br />103<br />104<br />105<br />106<br /></div></td><td valign="top"><pre style="margin: 0"><span style="color: #0000ff;">import</span> QtQuick <span style="color: #cc66cc;">2.5</span>
<span style="color: #0000ff;">import</span> QtQuick.<span style="color: #0080ff;">Window</span> <span style="color: #cc66cc;">2.2</span>
<span style="color: #0000ff;">import</span> QtQuick.Controls <span style="color: #cc66cc;">1.4</span>
<span style="color: #0000ff;">import</span> QtQuick.Layouts <span style="color: #cc66cc;">1.2</span>
&nbsp;
&nbsp;
<span style="color: #0080ff;">Window</span> <span style="color: black;">&#123;</span>
    <span style="color: #970009;">visible</span>: <span style="color: #339933;">true</span>
    <span style="color: #970009;">width</span>: <span style="color: #cc66cc;">800</span>; <span style="color: #970009;">height</span>: <span style="color: #cc66cc;">500</span>
    <span style="color: #970009;">x</span>: <span style="color: #cc66cc;">100</span> ; <span style="color: #970009;">y</span>: <span style="color: #cc66cc;">100</span>
    <span style="color: #970009;">title</span>: <span style="color: #FF0000;">&quot;Create curve with QML&quot;</span>
&nbsp;
&nbsp;
    <span style="color: #0080ff;">Rectangle</span><span style="color: black;">&#123;</span>
        <span style="color: #970009;">id</span>: root
        <span style="color: #970009;">anchors.fill</span>: parent
&nbsp;
        <span style="color: #0080ff;">ColumnLayout</span> <span style="color: black;">&#123;</span>
            <span style="color: #970009;">id</span>: grid
            <span style="color: #970009;">anchors.fill</span>: parent
&nbsp;
&nbsp;
            <span style="color: #0080ff;">RowLayout</span> <span style="color: black;">&#123;</span>
                <span style="color: #970009;">id</span>: control
                L<span style="color: #970009;">ayout.fillWidth</span>: <span style="color: #339933;">true</span>
                <span style="color: #970009;">implicitHeight</span>: <span style="color: #cc66cc;">25</span>
                <span style="color: #0080ff;">Button</span> <span style="color: black;">&#123;</span>
                    <span style="color: #970009;">text</span>: <span style="color: #FF0000;">&quot;Trace&quot;</span>
                <span style="color: black;">&#125;</span>
&nbsp;
                <span style="color: #0080ff;">Button</span> <span style="color: black;">&#123;</span>
                    <span style="color: #970009;">text</span>: <span style="color: #FF0000;">&quot;Efface&quot;</span>
                <span style="color: black;">&#125;</span>
&nbsp;
                <span style="color: #0080ff;">Slider</span> <span style="color: black;">&#123;</span>
                    <span style="color: #970009;">id</span>: slider
                    <span style="color: #970009;">value</span>: <span style="color: #cc66cc;">0</span>
                    <span style="color: #970009;">maximumValue</span>: <span style="color: #cc66cc;">20</span>
                <span style="color: black;">&#125;</span>
&nbsp;
                <span style="color: #0080ff;">Item</span> <span style="color: black;">&#123;</span>
                    L<span style="color: #970009;">ayout.fillWidth</span>: <span style="color: #339933;">true</span>
                <span style="color: black;">&#125;</span>
&nbsp;
                <span style="color: #0080ff;">Label</span> <span style="color: black;">&#123;</span>
                    <span style="color: #970009;">id</span>: posiX
                <span style="color: black;">&#125;</span>
&nbsp;
                <span style="color: #0080ff;">Label</span> <span style="color: black;">&#123;</span>
                    <span style="color: #970009;">id</span>: posiY
                <span style="color: black;">&#125;</span>
&nbsp;
                <span style="color: #0080ff;">Label</span> <span style="color: black;">&#123;</span>
                    <span style="color: #970009;">id</span>: posiX2
                <span style="color: black;">&#125;</span>
            <span style="color: black;">&#125;</span>
&nbsp;
            <span style="color: #0080ff;">Rectangle</span> <span style="color: black;">&#123;</span>
                <span style="color: #970009;">id</span>: area
                L<span style="color: #970009;">ayout.fillHeight</span>: <span style="color: #339933;">true</span>
                L<span style="color: #970009;">ayout.fillWidth</span>: <span style="color: #339933;">true</span>
                <span style="color: #970009;">color</span>: <span style="color: #FF0000;">&quot;lightgray&quot;</span>
                <span style="color: #0080ff;">Canvas</span> <span style="color: black;">&#123;</span>
                    <span style="color: #970009;">id</span>: canvas
                    <span style="color: #970009;">anchors.fill</span>: parent
                    <span style="color: #970009;">transform</span>: <span style="color: #0080ff;">Rotation</span> <span style="color: black;">&#123;</span> <span style="color: #970009;">origin.x</span>: area.x; <span style="color: #970009;">origin.y</span>: area.height/<span style="color: #cc66cc;">2</span>; <span style="color: #970009;">angle</span>: <span style="color: #cc66cc;">180</span>; axis <span style="color: black;">&#123;</span> <span style="color: #970009;">x</span>: <span style="color: #cc66cc;">1</span>; <span style="color: #970009;">y</span>: <span style="color: #cc66cc;">0</span>; <span style="color: #970009;">z</span>: <span style="color: #cc66cc;">0</span> <span style="color: black;">&#125;</span><span style="color: black;">&#125;</span>
                    <span style="color: #0000ff;">property</span> <span style="color: #0000ff;">int</span> <span style="color: #970009;">origX</span>: <span style="color: #cc66cc;">0</span>
                    <span style="color: #0000ff;">property</span> <span style="color: #0000ff;">int</span> <span style="color: #970009;">origY</span>: <span style="color: #cc66cc;">0</span>
                    <span style="color: #0000ff;">property</span> <span style="color: #0000ff;">int</span> <span style="color: #970009;">maxX</span>: width - origX
                    <span style="color: #0000ff;">property</span> <span style="color: #0000ff;">int</span> <span style="color: #970009;">maxY</span>: height - origY
&nbsp;
                    <span style="color: #0000ff;">property</span> <span style="color: #0000ff;">alias</span> <span style="color: #970009;">pointCurve</span>: pointCurve
&nbsp;
                    <span style="color: #008025;">/* c'est ici que &ccedil;a commence &agrave; devenir int&eacute;ressant. Comme pr&eacute;c&eacute;demment nous allons cr&eacute;er au d&eacute;marrage de l'application nos axes, mais nous n'irons pas plus loin.*/</span>
&nbsp;
                    <span style="color: #970009;">onPaint</span>:&nbsp;<span class="br0">&#123;</span></span>
<span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0080ff;">getContext</span><span class="br0">&#40;</span><span style="color: #FF0000;">&quot;2d&quot;</span><span class="br0">&#41;</span></span>
<span>&nbsp;</span>
<span><span style="color: #808080;">/* getContext(&quot;2d&quot;) est n&eacute;cessaire pour indiquer dans quel type de context nous nous trouvons. </span></span>
<span><span style="color: #808080;">Ici on d&eacute;clare donc un Context2D (http://doc.qt.io/qt-5/qml-qtquick-context2d-members.html) qui a notamment deux m&eacute;thodes qui nous int&eacute;resseront tout &nbsp;particuli&egrave;rement :</span></span>
<span><span style="color: #808080;">&nbsp; &nbsp;- beginPath()</span></span>
<span><span style="color: #808080;">&nbsp; &nbsp;- closePath()</span></span>
<span>&nbsp;</span>
<span><span style="color: #808080;">Entre ces deux m&eacute;thodes, vous pouvez cr&eacute;er comme bon vous semble diff&eacute;rents chemins et y appliquer un style unique (couleur, &eacute;paisseur du trait...) .</span></span>
<span><span style="color: #808080;">Pour appliquer d'autres styles il faudra red&eacute;clarer un nouveau Path (chemin en anglais).*/</span></span>
<span>&nbsp;</span>
<span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080;">/* Trace Axes */</span></span>
<span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; context.<span style="color: #0080ff;">beginPath</span><span class="br0">&#40;</span><span class="br0">&#41;</span></span>
<span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; context.lineWidth = <span style="color: #cc66cc;">2</span></span>
<span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; context.<span style="color: #0080ff;">moveTo</span><span class="br0">&#40;</span>origX, origY<span class="br0">&#41;</span> &nbsp;<span style="color: #808080;">// permet de se d&eacute;placer sans tracer de points</span></span>
<span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; context.<span style="color: #0080ff;">lineTo</span><span class="br0">&#40;</span>maxX, origY<span class="br0">&#41;</span> &nbsp; &nbsp;<span style="color: #808080;">// permet de tracer une ligne</span></span>
<span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; context.<span style="color: #0080ff;">moveTo</span><span class="br0">&#40;</span>origX, origY<span class="br0">&#41;</span></span>
<span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; context.<span style="color: #0080ff;">lineTo</span><span class="br0">&#40;</span>origX, maxY<span class="br0">&#41;</span></span>
<span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; context.strokeStyle = Qt.<span style="color: #0080ff;">rgba</span><span class="br0">&#40;</span><span style="color: #cc66cc;">0</span>,<span style="color: #cc66cc;">0</span>,<span style="color: #cc66cc;">0</span><span class="br0">&#41;</span>;</span>
<span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; context.<span style="color: #0080ff;">stroke</span><span class="br0">&#40;</span><span class="br0">&#41;</span></span>
<span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; context.<span style="color: #0080ff;">closePath</span><span class="br0">&#40;</span><span class="br0">&#41;</span></span>
<span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span>
&nbsp;
                    <span style="color: #0080ff;">ListModel</span><span style="color: black;">&#123;</span><span style="color: #970009;">id</span>: pointCurve<span style="color: black;">&#125;</span>
&nbsp;
&nbsp;
                <span style="color: black;">&#125;</span>
            <span style="color: black;">&#125;</span>
        <span style="color: black;">&#125;</span>
    <span style="color: black;">&#125;</span>
<span style="color: black;">&#125;</span></pre></td></tr></table></pre>
</div><br />
À ce stade vous devriez avoir quelque chose qui ressemble à ceci :<br />
<div style="text-align: center;"><img src="https://www.developpez.net/forums/attachments/p189665d1444287727/environnements-developpement/delphi/edi/kylix-indy-kylix-pb/1.png/" border="0" alt="Nom : 1.png
Affichages : 9814
Taille : 9,2 Ko"  style="float: CONFIG" /></div><br />
Nous allons maintenant créer notre courbe.<br />
<br />
Nous allons tout d'abord compléter nos composants Button et Slider afin de permettre l'interaction avec notre Canvas. Commençons par remplir notre ListModel des points à tracer :<br />
<div class="bbcode_container">
	<table width="100%" border="0" cellspacing="0" cellpadding="0"><tr>
	<td style="border: 0; padding: 0; text-align: left">Code qml :</td>
	<td style="border: 0; padding: 0; text-align: right"><a href="#" onclick="return ano_selectionnerCode(this);">Sélectionner tout</a> -
	<a href="#" onclick="return ano_etendreCode(this);">Visualiser dans une fenêtre à part</a></td></tr></table>
	<pre class="bbcode_code" style="height:144px;"><table cellspacing="0" cellpadding="0"><tr><td valign="top" width="26"><div style="border: 1px dashed gray; padding-left: 5px; padding-right: 5px; margin-right: 5px; text-align: right; font-family: monospace">1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br /></div></td><td valign="top"><pre style="margin: 0"><span style="color: #0080ff;">Button</span> <span style="color: black;">&#123;</span>
    <span style="color: #970009;">text</span>: <span style="color: #FF0000;">&quot;Trace&quot;</span>
    <span style="color: #970009;">onClicked</span>:&nbsp;<span class="br0">&#123;</span></span>
<span>&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">for</span> <span class="br0">&#40;</span><span style="color: #0000ff;">var</span> i=<span style="color: #cc66cc;">0</span>; i&lt;=<span style="color: #cc66cc;">20</span>; i++<span class="br0">&#41;</span><span class="br0">&#123;</span></span>
<span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; pointCurve.<span style="color: #0080ff;">append</span><span class="br0">&#40;</span><span class="br0">&#123;</span><span style="color: #FF0000;">&quot;x&quot;</span>:i*<span style="color: #cc66cc;">20</span>, <span style="color: #FF0000;">&quot;y&quot;</span>:<span style="color: #0080ff;">Math</span>.<span style="color: #0080ff;">pow</span><span class="br0">&#40;</span>i,<span style="color: #cc66cc;">2</span><span class="br0">&#41;</span><span class="br0">&#125;</span><span class="br0">&#41;</span></span>
<span>&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span></span>
<span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;canvas.<span style="color: #0080ff;">traceCurve</span><span class="br0">&#40;</span><span class="br0">&#41;</span> <span style="color: #808080;">// nous verrons cette fonction un peu plus bas.</span></span>
<span>&nbsp; &nbsp; <span class="br0">&#125;</span>
<span style="color: black;">&#125;</span></pre></td></tr></table></pre>
</div><br />
Puis la gestion de l'effacement de notre courbier :<br />
<div class="bbcode_container">
	<table width="100%" border="0" cellspacing="0" cellpadding="0"><tr>
	<td style="border: 0; padding: 0; text-align: left">Code qml :</td>
	<td style="border: 0; padding: 0; text-align: right"><a href="#" onclick="return ano_selectionnerCode(this);">Sélectionner tout</a> -
	<a href="#" onclick="return ano_etendreCode(this);">Visualiser dans une fenêtre à part</a></td></tr></table>
	<pre class="bbcode_code" style="height:120px;"><table cellspacing="0" cellpadding="0"><tr><td valign="top" width="26"><div style="border: 1px dashed gray; padding-left: 5px; padding-right: 5px; margin-right: 5px; text-align: right; font-family: monospace">1<br />2<br />3<br />4<br />5<br />6<br />7<br /></div></td><td valign="top"><pre style="margin: 0"><span style="color: #0080ff;">Button</span> <span style="color: black;">&#123;</span>
    <span style="color: #970009;">text</span>: <span style="color: #FF0000;">&quot;Efface&quot;</span>
    <span style="color: #970009;">onClicked</span>:&nbsp;<span class="br0">&#123;</span></span>
<span>&nbsp; &nbsp; &nbsp; &nbsp; slider.value = <span style="color: #cc66cc;">0</span></span>
<span>&nbsp; &nbsp; &nbsp; &nbsp; canvas.<span style="color: #0080ff;">clear</span><span class="br0">&#40;</span><span class="br0">&#41;</span> <span style="color: #808080;">// Comme pour canvas.traceCurve() nous verrons bient&ocirc;t cette fonction.</span></span>
<span>&nbsp; &nbsp; <span class="br0">&#125;</span>
<span style="color: black;">&#125;</span></pre></td></tr></table></pre>
</div><br />
Et enfin notre Slider qui nous permettra d'afficher un curseur :<br />
<div class="bbcode_container">
	<table width="100%" border="0" cellspacing="0" cellpadding="0"><tr>
	<td style="border: 0; padding: 0; text-align: left">Code qml :</td>
	<td style="border: 0; padding: 0; text-align: right"><a href="#" onclick="return ano_selectionnerCode(this);">Sélectionner tout</a> -
	<a href="#" onclick="return ano_etendreCode(this);">Visualiser dans une fenêtre à part</a></td></tr></table>
	<pre class="bbcode_code" style="height:144px;"><table cellspacing="0" cellpadding="0"><tr><td valign="top" width="26"><div style="border: 1px dashed gray; padding-left: 5px; padding-right: 5px; margin-right: 5px; text-align: right; font-family: monospace">1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br /></div></td><td valign="top"><pre style="margin: 0"><span style="color: #0080ff;">Slider</span> <span style="color: black;">&#123;</span>
    <span style="color: #970009;">id</span>: slider
    <span style="color: #970009;">value</span>: <span style="color: #cc66cc;">0</span>
    <span style="color: #970009;">maximumValue</span>: <span style="color: #cc66cc;">20</span>
    <span style="color: #970009;">onValueChanged</span>:&nbsp;<span class="br0">&#123;</span></span>
<span>&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">if</span> <span class="br0">&#40;</span>value !== <span style="color: #cc66cc;">0</span><span class="br0">&#41;</span>canvas.<span style="color: #0080ff;">point</span><span class="br0">&#40;</span>root.valueX*<span style="color: #cc66cc;">20</span>, <span style="color: #0080ff;">Math</span>.<span style="color: #0080ff;">pow</span><span class="br0">&#40;</span>root.valueX,<span style="color: #cc66cc;">2</span><span class="br0">&#41;</span><span class="br0">&#41;</span></span>
<span>&nbsp; &nbsp; &nbsp; &nbsp; canvas.<span style="color: #0080ff;">traceCurve</span><span class="br0">&#40;</span><span class="br0">&#41;</span></span>
<span>&nbsp; &nbsp; <span class="br0">&#125;</span>
<span style="color: black;">&#125;</span></pre></td></tr></table></pre>
</div><br />
Et voici enfin le moment tant attendu : le traçage de la courbe.<br />
<br />
Pour cela nous allons implémenter la fonction suivante : <br />
<div class="bbcode_container">
	<table width="100%" border="0" cellspacing="0" cellpadding="0"><tr>
	<td style="border: 0; padding: 0; text-align: left">Code qml :</td>
	<td style="border: 0; padding: 0; text-align: right"><a href="#" onclick="return ano_selectionnerCode(this);">Sélectionner tout</a> -
	<a href="#" onclick="return ano_etendreCode(this);">Visualiser dans une fenêtre à part</a></td></tr></table>
	<pre class="bbcode_code" style="height:204px;"><table cellspacing="0" cellpadding="0"><tr><td valign="top" width="33"><div style="border: 1px dashed gray; padding-left: 5px; padding-right: 5px; margin-right: 5px; text-align: right; font-family: monospace">1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br /></div></td><td valign="top"><pre style="margin: 0"><span style="color: #0000ff;">function</span> traceCurve<span style="color: black;">&#40;</span><span style="color: black;">&#41;</span> <span style="color: black;">&#123;</span>
    <span style="color: #0000ff;">if</span> <span style="color: black;">&#40;</span>context<span style="color: black;">&#41;</span><span style="color: black;">&#123;</span>
        context.beginPath<span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>                           <span style="color: #808080;">// comme pr&eacute;c&eacute;demment nous cr&eacute;ons un nouveau Path</span>
        context.lineWidth = <span style="color: #cc66cc;">1</span>
        <span style="color: #0000ff;">for</span> <span style="color: black;">&#40;</span><span style="color: #0000ff;">var</span> i = <span style="color: #cc66cc;">0</span>; i &lt; pointCurve.count; i++<span style="color: black;">&#41;</span> <span style="color: black;">&#123;</span>  <span style="color: #808080;">// Pour chaque &eacute;l&eacute;ment de notre ListModel, nous cr&eacute;ons une nouvelle ligne</span>
           <span style="color: #0000ff;">var</span> posiX = origX + pointCurve.get<span style="color: black;">&#40;</span>i<span style="color: black;">&#41;</span>.x
           <span style="color: #0000ff;">var</span> posiY = origY + pointCurve.get<span style="color: black;">&#40;</span>i<span style="color: black;">&#41;</span>.y
           context.lineTo<span style="color: black;">&#40;</span>posiX, posiY<span style="color: black;">&#41;</span>
       <span style="color: black;">&#125;</span>
       context.moveTo<span style="color: black;">&#40;</span>origX, origY<span style="color: black;">&#41;</span>
       context.strokeStyle = <span style="color: #0080ff;">Qt</span>.rgba<span style="color: black;">&#40;</span><span style="color: #cc66cc;">0</span>,<span style="color: #cc66cc;">0</span>,<span style="color: #cc66cc;">1</span><span style="color: black;">&#41;</span>;
       context.stroke<span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>                               <span style="color: #808080;">// Nous appliquons le style voulu</span>
       context.closePath<span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>                            <span style="color: #808080;">// Nous fermons notre chemin</span>
    <span style="color: black;">&#125;</span>
&nbsp;
requestPaint<span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>                                        <span style="color: #808080;">// et nous lan&ccedil;ons la requ&ecirc;te de rendu</span></pre></td></tr></table></pre>
</div><br />
<br />
Le principe pour tracer le curseur (fonction point () utilisée dans le Slider) est sensiblement le même.<br />
Pour effacer le contenu de notre Canvas il suffit d'effacer le contenu de notre ListModel, faire un reset du context et redonner l'ordre de tracer les nouveaux éléments : c'est à dire rien du tout.<br />
<div class="bbcode_container">
	<table width="100%" border="0" cellspacing="0" cellpadding="0"><tr>
	<td style="border: 0; padding: 0; text-align: left">Code qml :</td>
	<td style="border: 0; padding: 0; text-align: right"><a href="#" onclick="return ano_selectionnerCode(this);">Sélectionner tout</a> -
	<a href="#" onclick="return ano_etendreCode(this);">Visualiser dans une fenêtre à part</a></td></tr></table>
	<pre class="bbcode_code" style="height:120px;"><table cellspacing="0" cellpadding="0"><tr><td valign="top" width="26"><div style="border: 1px dashed gray; padding-left: 5px; padding-right: 5px; margin-right: 5px; text-align: right; font-family: monospace">1<br />2<br />3<br />4<br />5<br />6<br />7<br /></div></td><td valign="top"><pre style="margin: 0"><span style="color: #0000ff;">function</span> <span style="color: #0080ff;">clear</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="br0">&#123;</span></span>
<span>&nbsp; &nbsp; <span style="color: #0000ff;">if</span> <span class="br0">&#40;</span>context<span class="br0">&#41;</span><span class="br0">&#123;</span></span>
<span>&nbsp; &nbsp; &nbsp; &nbsp; pointCurve.<span style="color: #0080ff;">clear</span><span class="br0">&#40;</span><span class="br0">&#41;</span></span>
<span>&nbsp; &nbsp; &nbsp; &nbsp; context.<span style="color: #0080ff;">reset</span><span class="br0">&#40;</span><span class="br0">&#41;</span></span>
<span>&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0080ff;">requestPaint</span><span class="br0">&#40;</span><span class="br0">&#41;</span></span>
<span>&nbsp; &nbsp; <span class="br0">&#125;</span></span>
<span><span class="br0">&#125;</span></pre></td></tr></table></pre>
</div><br />
<br />
Voici ce que donne le code complet :<br />
<br />
<div class="bbcode_container">
	<table width="100%" border="0" cellspacing="0" cellpadding="0"><tr>
	<td style="border: 0; padding: 0; text-align: left">Code qml :</td>
	<td style="border: 0; padding: 0; text-align: right"><a href="#" onclick="return ano_selectionnerCode(this);">Sélectionner tout</a> -
	<a href="#" onclick="return ano_etendreCode(this);">Visualiser dans une fenêtre à part</a></td></tr></table>
	<pre class="bbcode_code" style="height:204px;"><table cellspacing="0" cellpadding="0"><tr><td valign="top" width="40"><div style="border: 1px dashed gray; padding-left: 5px; padding-right: 5px; margin-right: 5px; text-align: right; font-family: monospace">1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br />22<br />23<br />24<br />25<br />26<br />27<br />28<br />29<br />30<br />31<br />32<br />33<br />34<br />35<br />36<br />37<br />38<br />39<br />40<br />41<br />42<br />43<br />44<br />45<br />46<br />47<br />48<br />49<br />50<br />51<br />52<br />53<br />54<br />55<br />56<br />57<br />58<br />59<br />60<br />61<br />62<br />63<br />64<br />65<br />66<br />67<br />68<br />69<br />70<br />71<br />72<br />73<br />74<br />75<br />76<br />77<br />78<br />79<br />80<br />81<br />82<br />83<br />84<br />85<br />86<br />87<br />88<br />89<br />90<br />91<br />92<br />93<br />94<br />95<br />96<br />97<br />98<br />99<br />100<br />101<br />102<br />103<br />104<br />105<br />106<br />107<br />108<br />109<br />110<br />111<br />112<br />113<br />114<br />115<br />116<br />117<br />118<br />119<br />120<br />121<br />122<br />123<br />124<br />125<br />126<br />127<br />128<br />129<br />130<br />131<br />132<br />133<br />134<br />135<br />136<br />137<br />138<br />139<br />140<br />141<br />142<br />143<br />144<br />145<br />146<br />147<br />148<br />149<br /></div></td><td valign="top"><pre style="margin: 0"><span style="color: #0000ff;">import</span> QtQuick <span style="color: #cc66cc;">2.5</span>
<span style="color: #0000ff;">import</span> QtQuick.<span style="color: #0080ff;">Window</span> <span style="color: #cc66cc;">2.2</span>
<span style="color: #0000ff;">import</span> QtQuick.Controls <span style="color: #cc66cc;">1.4</span>
<span style="color: #0000ff;">import</span> QtQuick.Layouts <span style="color: #cc66cc;">1.2</span>
&nbsp;
&nbsp;
<span style="color: #0080ff;">Window</span> <span style="color: black;">&#123;</span>
    <span style="color: #970009;">visible</span>: <span style="color: #339933;">true</span>
    <span style="color: #970009;">width</span>: <span style="color: #cc66cc;">800</span>; <span style="color: #970009;">height</span>: <span style="color: #cc66cc;">500</span>
    <span style="color: #970009;">x</span>: <span style="color: #cc66cc;">100</span> ; <span style="color: #970009;">y</span>: <span style="color: #cc66cc;">100</span>
    <span style="color: #970009;">title</span>: <span style="color: #FF0000;">&quot;Create curve with QML&quot;</span>
&nbsp;
&nbsp;
    <span style="color: #0080ff;">Rectangle</span><span style="color: black;">&#123;</span>
        <span style="color: #970009;">id</span>: root
        <span style="color: #970009;">anchors.fill</span>: parent
&nbsp;
        <span style="color: #0000ff;">property</span> <span style="color: #0000ff;">alias</span> <span style="color: #970009;">valueX</span>: slider.value
&nbsp;
        <span style="color: #0080ff;">ColumnLayout</span> <span style="color: black;">&#123;</span>
            <span style="color: #970009;">id</span>: grid
            <span style="color: #970009;">anchors.fill</span>: parent
&nbsp;
&nbsp;
            <span style="color: #0080ff;">RowLayout</span> <span style="color: black;">&#123;</span>
                <span style="color: #970009;">id</span>: control
                L<span style="color: #970009;">ayout.fillWidth</span>: <span style="color: #339933;">true</span>
                <span style="color: #970009;">implicitHeight</span>: <span style="color: #cc66cc;">25</span>
                <span style="color: #0080ff;">Button</span> <span style="color: black;">&#123;</span>
                    <span style="color: #970009;">text</span>: <span style="color: #FF0000;">&quot;Trace&quot;</span>
                    <span style="color: #970009;">onClicked</span>:&nbsp;<span class="br0">&#123;</span></span>
<span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">for</span> <span class="br0">&#40;</span><span style="color: #0000ff;">var</span> i=<span style="color: #cc66cc;">0</span>; i&lt;=<span style="color: #cc66cc;">20</span>; i++<span class="br0">&#41;</span><span class="br0">&#123;</span></span>
<span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; pointCurve.<span style="color: #0080ff;">append</span><span class="br0">&#40;</span><span class="br0">&#123;</span><span style="color: #FF0000;">&quot;x&quot;</span>:i*<span style="color: #cc66cc;">20</span>, <span style="color: #FF0000;">&quot;y&quot;</span>:<span style="color: #0080ff;">Math</span>.<span style="color: #0080ff;">pow</span><span class="br0">&#40;</span>i,<span style="color: #cc66cc;">2</span><span class="br0">&#41;</span><span class="br0">&#125;</span><span class="br0">&#41;</span></span>
<span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span></span>
<span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; canvas.<span style="color: #0080ff;">traceCurve</span><span class="br0">&#40;</span><span class="br0">&#41;</span></span>
<span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span>
                <span style="color: black;">&#125;</span>
                <span style="color: #0080ff;">Button</span> <span style="color: black;">&#123;</span>
                    <span style="color: #970009;">text</span>: <span style="color: #FF0000;">&quot;Efface&quot;</span>
                    <span style="color: #970009;">onClicked</span>:&nbsp;<span class="br0">&#123;</span></span>
<span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; slider.value = <span style="color: #cc66cc;">0</span></span>
<span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; canvas.<span style="color: #0080ff;">clear</span><span class="br0">&#40;</span><span class="br0">&#41;</span></span>
<span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span>
                <span style="color: black;">&#125;</span>
                <span style="color: #0080ff;">Slider</span> <span style="color: black;">&#123;</span>
                    <span style="color: #970009;">id</span>: slider
                    <span style="color: #970009;">value</span>: <span style="color: #cc66cc;">0</span>
                    <span style="color: #970009;">maximumValue</span>: <span style="color: #cc66cc;">20</span>
                    <span style="color: #970009;">onValueChanged</span>:&nbsp;<span class="br0">&#123;</span></span>
<span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">if</span> <span class="br0">&#40;</span>value !== <span style="color: #cc66cc;">0</span><span class="br0">&#41;</span>canvas.<span style="color: #0080ff;">point</span><span class="br0">&#40;</span>root.valueX*<span style="color: #cc66cc;">20</span>, <span style="color: #0080ff;">Math</span>.<span style="color: #0080ff;">pow</span><span class="br0">&#40;</span>root.valueX,<span style="color: #cc66cc;">2</span><span class="br0">&#41;</span><span class="br0">&#41;</span></span>
<span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; canvas.<span style="color: #0080ff;">traceCurve</span><span class="br0">&#40;</span><span class="br0">&#41;</span></span>
<span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span>
                <span style="color: black;">&#125;</span>
                <span style="color: #0080ff;">Item</span> <span style="color: black;">&#123;</span>
                    L<span style="color: #970009;">ayout.fillWidth</span>: <span style="color: #339933;">true</span>
                <span style="color: black;">&#125;</span>
&nbsp;
                <span style="color: #0080ff;">Label</span> <span style="color: black;">&#123;</span>
                    <span style="color: #970009;">id</span>: posiX
                    <span style="color: #970009;">text</span>: <span style="color: #FF0000;">&quot;x : &quot;</span> + <span style="color: black;">&#40;</span>root.valueX*<span style="color: #cc66cc;">20</span><span style="color: black;">&#41;</span>.toFixed<span style="color: black;">&#40;</span><span style="color: #cc66cc;">2</span><span style="color: black;">&#41;</span>
                <span style="color: black;">&#125;</span>
                <span style="color: #0080ff;">Label</span> <span style="color: black;">&#123;</span>
                    <span style="color: #970009;">id</span>: posiY
                    <span style="color: #970009;">text</span>: <span style="color: #FF0000;">&quot;y : &quot;</span> + Math.pow<span style="color: black;">&#40;</span>root.valueX,<span style="color: #cc66cc;">2</span><span style="color: black;">&#41;</span>.toFixed<span style="color: black;">&#40;</span><span style="color: #cc66cc;">2</span><span style="color: black;">&#41;</span>
                <span style="color: black;">&#125;</span>
                <span style="color: #0080ff;">Label</span> <span style="color: black;">&#123;</span>
                    <span style="color: #970009;">id</span>: posiX2
                <span style="color: black;">&#125;</span>
            <span style="color: black;">&#125;</span>
&nbsp;
            <span style="color: #0080ff;">Rectangle</span> <span style="color: black;">&#123;</span>
                <span style="color: #970009;">id</span>: area
                L<span style="color: #970009;">ayout.fillHeight</span>: <span style="color: #339933;">true</span>
                L<span style="color: #970009;">ayout.fillWidth</span>: <span style="color: #339933;">true</span>
                <span style="color: #970009;">color</span>: <span style="color: #FF0000;">&quot;lightgray&quot;</span>
                <span style="color: #0080ff;">Canvas</span> <span style="color: black;">&#123;</span>
                    <span style="color: #970009;">id</span>: canvas
                    <span style="color: #970009;">anchors.fill</span>: parent
                    <span style="color: #970009;">transform</span>: <span style="color: #0080ff;">Rotation</span> <span style="color: black;">&#123;</span> <span style="color: #970009;">origin.x</span>: area.x; <span style="color: #970009;">origin.y</span>: area.height/<span style="color: #cc66cc;">2</span>; <span style="color: #970009;">angle</span>: <span style="color: #cc66cc;">180</span>; axis <span style="color: black;">&#123;</span> <span style="color: #970009;">x</span>: <span style="color: #cc66cc;">1</span>; <span style="color: #970009;">y</span>: <span style="color: #cc66cc;">0</span>; <span style="color: #970009;">z</span>: <span style="color: #cc66cc;">0</span> <span style="color: black;">&#125;</span><span style="color: black;">&#125;</span>
                    <span style="color: #0000ff;">property</span> <span style="color: #0000ff;">int</span> <span style="color: #970009;">origX</span>: <span style="color: #cc66cc;">0</span>
                    <span style="color: #0000ff;">property</span> <span style="color: #0000ff;">int</span> <span style="color: #970009;">origY</span>: <span style="color: #cc66cc;">0</span>
                    <span style="color: #0000ff;">property</span> <span style="color: #0000ff;">int</span> <span style="color: #970009;">maxX</span>: width - origX
                    <span style="color: #0000ff;">property</span> <span style="color: #0000ff;">int</span> <span style="color: #970009;">maxY</span>: height - origY
&nbsp;
                    <span style="color: #0000ff;">property</span> <span style="color: #0000ff;">alias</span> <span style="color: #970009;">pointCurve</span>: pointCurve
&nbsp;
&nbsp;
&nbsp;
                    <span style="color: #0000ff;">function</span> <span style="color: #0080ff;">clear</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="br0">&#123;</span></span>
<span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">if</span> <span class="br0">&#40;</span>context<span class="br0">&#41;</span><span class="br0">&#123;</span></span>
<span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; pointCurve.<span style="color: #0080ff;">clear</span><span class="br0">&#40;</span><span class="br0">&#41;</span></span>
<span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; context.<span style="color: #0080ff;">reset</span><span class="br0">&#40;</span><span class="br0">&#41;</span></span>
<span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0080ff;">requestPaint</span><span class="br0">&#40;</span><span class="br0">&#41;</span></span>
<span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span></span>
<span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span>
&nbsp;
                    <span style="color: #0000ff;">function</span> <span style="color: #0080ff;">point</span><span class="br0">&#40;</span>q, h<span class="br0">&#41;</span><span class="br0">&#123;</span></span>
<span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; context.<span style="color: #0080ff;">reset</span><span class="br0">&#40;</span><span class="br0">&#41;</span></span>
<span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; context.<span style="color: #0080ff;">beginPath</span><span class="br0">&#40;</span><span class="br0">&#41;</span></span>
<span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; context.lineWidth = <span style="color: #cc66cc;">1</span></span>
<span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; context.<span style="color: #0080ff;">moveTo</span><span class="br0">&#40;</span>origX, h+origY<span class="br0">&#41;</span></span>
<span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; context.<span style="color: #0080ff;">lineTo</span><span class="br0">&#40;</span>maxX, h+origY<span class="br0">&#41;</span></span>
<span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; context.<span style="color: #0080ff;">moveTo</span><span class="br0">&#40;</span>q+origX, origY<span class="br0">&#41;</span></span>
<span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; context.<span style="color: #0080ff;">lineTo</span><span class="br0">&#40;</span>q+origX, maxY<span class="br0">&#41;</span></span>
<span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; context.strokeStyle = Qt.<span style="color: #0080ff;">rgba</span><span class="br0">&#40;</span><span style="color: #cc66cc;">1</span>,<span style="color: #cc66cc;">0</span>,<span style="color: #cc66cc;">0</span><span class="br0">&#41;</span>;</span>
<span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; context.<span style="color: #0080ff;">stroke</span><span class="br0">&#40;</span><span class="br0">&#41;</span></span>
<span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; context.<span style="color: #0080ff;">closePath</span><span class="br0">&#40;</span><span class="br0">&#41;</span></span>
<span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0080ff;">requestPaint</span><span class="br0">&#40;</span><span class="br0">&#41;</span></span>
<span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span>
&nbsp;
                    <span style="color: #0000ff;">function</span> <span style="color: #0080ff;">traceCurve</span><span class="br0">&#40;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span></span>
<span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">if</span> <span class="br0">&#40;</span>context<span class="br0">&#41;</span><span class="br0">&#123;</span></span>
<span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; context.<span style="color: #0080ff;">beginPath</span><span class="br0">&#40;</span><span class="br0">&#41;</span></span>
<span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; context.lineWidth = <span style="color: #cc66cc;">1</span></span>
<span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">for</span> <span class="br0">&#40;</span><span style="color: #0000ff;">var</span> i = <span style="color: #cc66cc;">0</span>; i &lt; pointCurve.count; i++<span class="br0">&#41;</span> <span class="br0">&#123;</span></span>
<span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">var</span> posiX = origX + pointCurve.<span style="color: #0080ff;">get</span><span class="br0">&#40;</span>i<span class="br0">&#41;</span>.x</span>
<span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">var</span> posiY = origY + pointCurve.<span style="color: #0080ff;">get</span><span class="br0">&#40;</span>i<span class="br0">&#41;</span>.y</span>
<span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; context.<span style="color: #0080ff;">lineTo</span><span class="br0">&#40;</span>posiX, posiY<span class="br0">&#41;</span></span>
<span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span></span>
<span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; context.<span style="color: #0080ff;">moveTo</span><span class="br0">&#40;</span>origX, origY<span class="br0">&#41;</span></span>
<span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; context.strokeStyle = Qt.<span style="color: #0080ff;">rgba</span><span class="br0">&#40;</span><span style="color: #cc66cc;">0</span>,<span style="color: #cc66cc;">0</span>,<span style="color: #cc66cc;">1</span><span class="br0">&#41;</span>;</span>
<span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; context.<span style="color: #0080ff;">stroke</span><span class="br0">&#40;</span><span class="br0">&#41;</span></span>
<span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; context.<span style="color: #0080ff;">closePath</span><span class="br0">&#40;</span><span class="br0">&#41;</span></span>
<span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span></span>
<span>&nbsp;</span>
<span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0080ff;">requestPaint</span><span class="br0">&#40;</span><span class="br0">&#41;</span></span>
<span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span>
&nbsp;
                    <span style="color: #970009;">onPaint</span>:&nbsp;<span class="br0">&#123;</span></span>
<span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0080ff;">getContext</span><span class="br0">&#40;</span><span style="color: #FF0000;">&quot;2d&quot;</span><span class="br0">&#41;</span></span>
<span>&nbsp;</span>
<span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080;">/* Trace Axes */</span></span>
<span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; context.<span style="color: #0080ff;">beginPath</span><span class="br0">&#40;</span><span class="br0">&#41;</span></span>
<span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; context.lineWidth = <span style="color: #cc66cc;">2</span></span>
<span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; context.<span style="color: #0080ff;">moveTo</span><span class="br0">&#40;</span>origX, origY<span class="br0">&#41;</span></span>
<span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; context.<span style="color: #0080ff;">lineTo</span><span class="br0">&#40;</span>maxX, origY<span class="br0">&#41;</span></span>
<span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; context.<span style="color: #0080ff;">moveTo</span><span class="br0">&#40;</span>origX, origY<span class="br0">&#41;</span></span>
<span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; context.<span style="color: #0080ff;">lineTo</span><span class="br0">&#40;</span>origX, maxY<span class="br0">&#41;</span></span>
<span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; context.strokeStyle = Qt.<span style="color: #0080ff;">rgba</span><span class="br0">&#40;</span><span style="color: #cc66cc;">0</span>,<span style="color: #cc66cc;">0</span>,<span style="color: #cc66cc;">0</span><span class="br0">&#41;</span>;</span>
<span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; context.<span style="color: #0080ff;">stroke</span><span class="br0">&#40;</span><span class="br0">&#41;</span></span>
<span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; context.<span style="color: #0080ff;">closePath</span><span class="br0">&#40;</span><span class="br0">&#41;</span></span>
<span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span>
&nbsp;
                    <span style="color: #0080ff;">ListModel</span><span style="color: black;">&#123;</span><span style="color: #970009;">id</span>: pointCurve<span style="color: black;">&#125;</span>
                <span style="color: black;">&#125;</span>
            <span style="color: black;">&#125;</span>
        <span style="color: black;">&#125;</span>
    <span style="color: black;">&#125;</span>
<span style="color: black;">&#125;</span></pre></td></tr></table></pre>
</div>Vous avez maintenant en main de quoi réaliser de belles courbes dynamiquement, alimentées par vos calculs les plus fous ou votre super base de données 8-)</blockquote>

]]></content:encoded>
			<dc:creator>Jiyuu</dc:creator>
			<guid isPermaLink="true">https://www.developpez.net/forums/blogs/135545-jiyuu/b792/creation-dynamique-d-courbe-qml/</guid>
		</item>
		<item>
			<title>Afficher un PDF dans une application QML</title>
			<link>https://www.developpez.net/forums/blogs/135545-jiyuu/b787/afficher-pdf-application-qml/</link>
			<pubDate>Wed, 30 Sep 2015 13:27:26 GMT</pubDate>
			<description>:salut: à tous, 
 
Il existe...</description>
			<content:encoded><![CDATA[<blockquote class="blogcontent restore">:salut: à tous,<br />
<br />
Il existe plusieurs méthodes permettant d'afficher un PDF dans une application Qt, donc de facto dans une application QML.<br />
Nous allons voir dans ce billet comment faire ceci pour un projet QML en utilisant <a href="https://mozilla.github.io/pdf.js/getting_started/#download" target="_blank">pdf.js</a> avec notamment la visionneuse par défaut que cet outil propose (vous pouvez d'ores et déjà télécharger l'archive fournie)<br />
<br />
La solution que nous allons voir ici est relativement simple : pdf.js permet d'afficher un fichier PDF dans un navigateur. Il est possible de créer son propre navigateur avec QML et en particulier avec WebEngineView. Nous allons tout simplement utiliser celui-ci afin d'obtenir le résultat attendu.<br />
<br />
Tout d'abord le code QML permettant de disposer d'un navigateur web :<br />
<div class="bbcode_container">
	<table width="100%" border="0" cellspacing="0" cellpadding="0"><tr>
	<td style="border: 0; padding: 0; text-align: left">Code qml :</td>
	<td style="border: 0; padding: 0; text-align: right"><a href="#" onclick="return ano_selectionnerCode(this);">Sélectionner tout</a> -
	<a href="#" onclick="return ano_etendreCode(this);">Visualiser dans une fenêtre à part</a></td></tr></table>
	<pre class="bbcode_code" style="height:132px;"><table cellspacing="0" cellpadding="0"><tr><td valign="top" width="26"><div style="border: 1px dashed gray; padding-left: 5px; padding-right: 5px; margin-right: 5px; text-align: right; font-family: monospace">1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br /></div></td><td valign="top"><pre style="margin: 0"><span style="color: #0000ff;">import</span> QtQuick <span style="color: #cc66cc;">2.5</span>
<span style="color: #0000ff;">import</span> QtWebEngine <span style="color: #cc66cc;">1.0</span>
&nbsp;
WebEngineView <span style="color: black;">&#123;</span>
    <span style="color: #970009;">width</span>: <span style="color: #cc66cc;">800</span>
    <span style="color: #970009;">height</span>: <span style="color: #cc66cc;">600</span>
    <span style="color: #970009;">url</span>: <span style="color: #FF0000;">&quot;http://www.developpez.net/forums/blogs/135545-jiyuu/&quot;</span>
<span style="color: black;">&#125;</span></pre></td></tr></table></pre>
</div><br />
Rien de très compliqué (normal c'est du QML :mrgreen:)<br />
<br />
<br />
Étant donné que nous allons devoir utiliser <b>la visionneuse de pdf.js</b> afin d'<b>afficher un pdf</b> je vous propose la modification suivante du code précédent :<br />
<div class="bbcode_container">
	<table width="100%" border="0" cellspacing="0" cellpadding="0"><tr>
	<td style="border: 0; padding: 0; text-align: left">Code qml :</td>
	<td style="border: 0; padding: 0; text-align: right"><a href="#" onclick="return ano_selectionnerCode(this);">Sélectionner tout</a> -
	<a href="#" onclick="return ano_etendreCode(this);">Visualiser dans une fenêtre à part</a></td></tr></table>
	<pre class="bbcode_code" style="height:192px;"><table cellspacing="0" cellpadding="0"><tr><td valign="top" width="33"><div style="border: 1px dashed gray; padding-left: 5px; padding-right: 5px; margin-right: 5px; text-align: right; font-family: monospace">1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br /></div></td><td valign="top"><pre style="margin: 0"><span style="color: #0000ff;">import</span> QtQuick <span style="color: #cc66cc;">2.5</span>
<span style="color: #0000ff;">import</span> QtWebEngine <span style="color: #cc66cc;">1.0</span>
&nbsp;
WebEngineView <span style="color: black;">&#123;</span>
    <span style="color: #970009;">id</span>: webview
    <span style="color: #0000ff;">property</span> <span style="color: #0000ff;">string</span> viewer    <span style="color: #808080;">// chemin absolu pointant vers notre fichier viewer.html derni&egrave;rement t&eacute;l&eacute;charg&eacute;.</span>
    <span style="color: #0000ff;">property</span> <span style="color: #0000ff;">string</span> pathPdf  <span style="color: #808080;">// chemin absolu pointant vers le document pdf &agrave; afficher.</span>
&nbsp;
    <span style="color: #808080;">// le code ci-dessous permettra d'afficher une page blanche si au moins l'un des deux chemins n'est pas renseign&eacute;</span>
   <span style="color: #970009;">url</span>: <span style="color: #0000ff;">if</span> <span style="color: black;">&#40;</span>viewer &amp;&amp; pathPdf<span style="color: black;">&#41;</span>
         <span style="color: black;">&#123;</span>
             viewer + <span style="color: #FF0000;">&quot;?file=&quot;</span> + pathPdf
         <span style="color: black;">&#125;</span>
<span style="color: black;">&#125;</span></pre></td></tr></table></pre>
</div><br />
Il ne vous reste plus qu'à utiliser ce composant dans votre projet afin d'y afficher le PDF voulu.</blockquote>

]]></content:encoded>
			<dc:creator>Jiyuu</dc:creator>
			<guid isPermaLink="true">https://www.developpez.net/forums/blogs/135545-jiyuu/b787/afficher-pdf-application-qml/</guid>
		</item>
		<item>
			<title>Interaction entre C++ et QML. Première méthode : en avant la facilité</title>
			<link>https://www.developpez.net/forums/blogs/135545-jiyuu/b757/interaction-entre-cpp-qml-premiere-methode-facilite/</link>
			<pubDate>Fri, 18 Sep 2015 10:10:59 GMT</pubDate>
			<description><![CDATA[Dans l'un de mes articles...]]></description>
			<content:encoded><![CDATA[<blockquote class="blogcontent restore">Dans l'un de <a href="http://ceg.developpez.com/tutoriels/pyqt/qt-quick-python/02-interaction-qml-python" target="_blank">mes articles</a> je traite des manières d'interagir entre le code Python et le code QML.<br />
<br />
Je vous propose ici d'aborder le sujet, mais avec un code C++. Les lignes qui suivent présentent une première méthode, qui à mon sens est la plus simple, mais peut-être pas la plus &quot;corporate&quot;.<br />
<br />
<i><b>Important</b> : le but de ce billet n'est pas de présenter QML. On suppose donc que vous connaissez déjà un peu ce langage.</i><br />
<br />
Si vous utilisez Qt Creator commencez par créer un nouveau projet et choisissez l'option Qt Quick Controls Application. La capture d'écran qui suit correspond à la fenêtre que vous aurez avec Qt Creator 3.5, c'est-à-dire la version la plus récente au moment d'écrire ces quelques lignes :<br />
<img src="https://www.developpez.net/forums/attachments/p188217d1442515951/autres-langages/autres-langages/corba/partage-d-tableau-dynamique-2-dimensions-visibroker/screen1.png/" border="0" alt="Nom : screen1.png
Affichages : 13789
Taille : 38,8 Ko"  style="float: CONFIG" /><br />
<br />
Maintenant je vous propose de modifier le code qml afin d'ajouter un bouton :<br />
<br />
<div class="bbcode_container">
	<table width="100%" border="0" cellspacing="0" cellpadding="0"><tr>
	<td style="border: 0; padding: 0; text-align: left">Code qml :</td>
	<td style="border: 0; padding: 0; text-align: right"><a href="#" onclick="return ano_selectionnerCode(this);">Sélectionner tout</a> -
	<a href="#" onclick="return ano_etendreCode(this);">Visualiser dans une fenêtre à part</a></td></tr></table>
	<pre class="bbcode_code" style="height:204px;"><table cellspacing="0" cellpadding="0"><tr><td valign="top" width="33"><div style="border: 1px dashed gray; padding-left: 5px; padding-right: 5px; margin-right: 5px; text-align: right; font-family: monospace">1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br />22<br />23<br />24<br />25<br />26<br />27<br />28<br />29<br />30<br />31<br />32<br />33<br />34<br />35<br />36<br /></div></td><td valign="top"><pre style="margin: 0"><span style="color: #0000ff;">import</span> QtQuick <span style="color: #cc66cc;">2.5</span>
<span style="color: #0000ff;">import</span> QtQuick.Controls <span style="color: #cc66cc;">1.4</span>
&nbsp;
<span style="color: #0080ff;">ApplicationWindow</span> <span style="color: black;">&#123;</span>
    <span style="color: #970009;">visible</span>: <span style="color: #339933;">true</span>
    <span style="color: #970009;">width</span>: <span style="color: #cc66cc;">640</span>
    <span style="color: #970009;">height</span>: <span style="color: #cc66cc;">480</span>
    <span style="color: #970009;">title</span>: qsTr<span style="color: black;">&#40;</span><span style="color: #FF0000;">&quot;Hello World&quot;</span><span style="color: black;">&#41;</span>
&nbsp;
    <span style="color: #970009;">menuBar</span>: <span style="color: #0080ff;">MenuBar</span> <span style="color: black;">&#123;</span>
        <span style="color: #0080ff;">Menu</span> <span style="color: black;">&#123;</span>
            <span style="color: #970009;">title</span>: qsTr<span style="color: black;">&#40;</span><span style="color: #FF0000;">&quot;File&quot;</span><span style="color: black;">&#41;</span>
            <span style="color: #0080ff;">MenuItem</span> <span style="color: black;">&#123;</span>
                <span style="color: #970009;">text</span>: qsTr<span style="color: black;">&#40;</span><span style="color: #FF0000;">&quot;&amp;Open&quot;</span><span style="color: black;">&#41;</span>
                <span style="color: #970009;">onTriggered</span>: console.log<span style="color: black;">&#40;</span><span style="color: #FF0000;">&quot;Open action triggered&quot;</span><span style="color: black;">&#41;</span>;
            <span style="color: black;">&#125;</span>
            <span style="color: #0080ff;">MenuItem</span> <span style="color: black;">&#123;</span>
                <span style="color: #970009;">text</span>: qsTr<span style="color: black;">&#40;</span><span style="color: #FF0000;">&quot;Exit&quot;</span><span style="color: black;">&#41;</span>
                <span style="color: #970009;">onTriggered</span>: <span style="color: #0080ff;">Qt</span>.quit<span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>;
            <span style="color: black;">&#125;</span>
        <span style="color: black;">&#125;</span>
    <span style="color: black;">&#125;</span>
&nbsp;
    <span style="color: #0080ff;">Label</span> <span style="color: black;">&#123;</span>
        <span style="color: #970009;">id</span>: label
        <span style="color: #970009;">text</span>: qsTr<span style="color: black;">&#40;</span><span style="color: #FF0000;">&quot;Hello World&quot;</span><span style="color: black;">&#41;</span>
        <span style="color: #970009;">x</span>: <span style="color: #cc66cc;">5</span> ; <span style="color: #970009;">y</span>: <span style="color: #cc66cc;">5</span>
        <span style="color: #970009;">width</span>: parent.width
        <span style="color: #970009;">height</span>: <span style="color: #cc66cc;">50</span>
    <span style="color: black;">&#125;</span>
    <span style="color: #0080ff;">Button</span><span style="color: black;">&#123;</span>
        <span style="color: #970009;">x</span>: <span style="color: #cc66cc;">5</span> ; <span style="color: #970009;">y</span>: <span style="color: #cc66cc;">100</span>
        <span style="color: #970009;">text</span>: qsTr<span style="color: black;">&#40;</span><span style="color: #FF0000;">&quot;Click here&quot;</span><span style="color: black;">&#41;</span>
        <span style="color: #970009;">onClicked</span>: label.text = comCpp.txt<span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>  <span style="color: #808080;">// les lignes qui suivent expliquent ce qu'est comCpp.txt()</span>
    <span style="color: black;">&#125;</span>
<span style="color: black;">&#125;</span></pre></td></tr></table></pre>
</div><br />
Nous allons ensuite modifier notre main.cpp comme suit :<br />
<div class="bbcode_container">
	<table width="100%" border="0" cellspacing="0" cellpadding="0"><tr>
	<td style="border: 0; padding: 0; text-align: left">Code c++ :</td>
	<td style="border: 0; padding: 0; text-align: right"><a href="#" onclick="return ano_selectionnerCode(this);">Sélectionner tout</a> -
	<a href="#" onclick="return ano_etendreCode(this);">Visualiser dans une fenêtre à part</a></td></tr></table>
	<pre class="bbcode_code" style="height:204px;"><table cellspacing="0" cellpadding="0"><tr><td valign="top" width="33"><div style="border: 1px dashed gray; padding-left: 5px; padding-right: 5px; margin-right: 5px; text-align: right; font-family: monospace">1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br /></div></td><td valign="top"><pre style="margin: 0"><span style="color: #339933;">#include</span><span style="color: #FF0000;"> &lt;QGuiApplication&gt;</span>
<span style="color: #339933;">#include</span><span style="color: #FF0000;"> &lt;QQmlApplicationEngine&gt;</span>
<span style="color: #339933;">#include</span><span style="color: #FF0000;"> &lt;QQmlContext&gt;</span>  <span style="color: #808080;">// n&eacute;cessaire pour dialoguer entre le code C++ et le code QML</span>
<span style="color: #339933;">#include</span><span style="color: #FF0000;"> &lt;comcpp.h&gt;</span>  <span style="color: #808080;">// correspond &agrave; une classe que nous allons construire ensuite.</span>
&nbsp;
<span style="color: #0000ff;">int</span> main<span style="color: black;">&#40;</span><span style="color: #0000ff;">int</span> argc, <span style="color: #0000ff;">char</span> *argv<span style="color: black;">&#91;</span><span style="color: black;">&#93;</span><span style="color: black;">&#41;</span>
<span style="color: black;">&#123;</span>
    QGuiApplication app<span style="color: black;">&#40;</span>argc, argv<span style="color: black;">&#41;</span>;
    ComCpp compCpp; 
&nbsp;
    QQmlApplicationEngine engine;
    engine.rootContext<span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>-&gt;setContextProperty<span style="color: black;">&#40;</span><span style="color: #FF0000;">&quot;comCpp&quot;</span>, &amp;compCpp<span style="color: black;">&#41;</span>; <span style="color: #808080;">// nous passons ensuite notre object comCpp comme contextProperty dans notre QML. C'est ainsi que nous pourrons l'utiliser.</span>
    engine.load<span style="color: black;">&#40;</span>QUrl<span style="color: black;">&#40;</span>QStringLiteral<span style="color: black;">&#40;</span><span style="color: #FF0000;">&quot;qrc:/main.qml&quot;</span><span style="color: black;">&#41;</span><span style="color: black;">&#41;</span><span style="color: black;">&#41;</span>;
&nbsp;
    <span style="color: #0000ff;">return</span> app.exec<span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>;
<span style="color: black;">&#125;</span></pre></td></tr></table></pre>
</div><br />
Créons maintenant notre classe ComCpp en y ajoutant le slot txt():<br />
<i>comcpp.h</i><br />
<div class="bbcode_container">
	<table width="100%" border="0" cellspacing="0" cellpadding="0"><tr>
	<td style="border: 0; padding: 0; text-align: left">Code c++ :</td>
	<td style="border: 0; padding: 0; text-align: right"><a href="#" onclick="return ano_selectionnerCode(this);">Sélectionner tout</a> -
	<a href="#" onclick="return ano_etendreCode(this);">Visualiser dans une fenêtre à part</a></td></tr></table>
	<pre class="bbcode_code" style="height:204px;"><table cellspacing="0" cellpadding="0"><tr><td valign="top" width="33"><div style="border: 1px dashed gray; padding-left: 5px; padding-right: 5px; margin-right: 5px; text-align: right; font-family: monospace">1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br /></div></td><td valign="top"><pre style="margin: 0"><span style="color: #339933;">#ifndef COMCPP_H</span>
<span style="color: #339933;">#define COMCPP_H</span>
&nbsp;
<span style="color: #339933;">#include</span><span style="color: #FF0000;"> &lt;QString&gt;</span>
<span style="color: #339933;">#include</span><span style="color: #FF0000;"> &lt;QObject&gt;</span>
&nbsp;
&nbsp;
<span style="color: #0000ff;">class</span> ComCpp : <span style="color: #0000ff;">public</span> QObject  <span style="color: #808080;">// IMPORTANT : pour &ecirc;tre utilisable dans le code QML, votre classe doit d&eacute;river de QObject ou QQuickItem.</span>
<span style="color: black;">&#123;</span>
    Q_OBJECT
<span style="color: #0000ff;">public</span>:
    <span style="color: #0000ff;">explicit</span> ComCpp<span style="color: black;">&#40;</span>QObject *parent = <span style="color: #cc66cc;">0</span><span style="color: black;">&#41;</span>;
&nbsp;
signals:
&nbsp;
<span style="color: #0000ff;">public</span> slots:
    QString txt<span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>;
<span style="color: black;">&#125;</span>;
&nbsp;
<span style="color: #339933;">#endif // COMCPP_H</span></pre></td></tr></table></pre>
</div><br />
<i>comcpp.cpp</i><br />
<div class="bbcode_container">
	<table width="100%" border="0" cellspacing="0" cellpadding="0"><tr>
	<td style="border: 0; padding: 0; text-align: left">Code c++ :</td>
	<td style="border: 0; padding: 0; text-align: right"><a href="#" onclick="return ano_selectionnerCode(this);">Sélectionner tout</a> -
	<a href="#" onclick="return ano_etendreCode(this);">Visualiser dans une fenêtre à part</a></td></tr></table>
	<pre class="bbcode_code" style="height:168px;"><table cellspacing="0" cellpadding="0"><tr><td valign="top" width="33"><div style="border: 1px dashed gray; padding-left: 5px; padding-right: 5px; margin-right: 5px; text-align: right; font-family: monospace">1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br /></div></td><td valign="top"><pre style="margin: 0"><span style="color: #339933;">#include</span><span style="color: #FF0000;"> &quot;comcpp.h&quot;</span>
&nbsp;
ComCpp::ComCpp<span style="color: black;">&#40;</span>QObject *parent<span style="color: black;">&#41;</span> : QObject<span style="color: black;">&#40;</span>parent<span style="color: black;">&#41;</span>
<span style="color: black;">&#123;</span>
&nbsp;
<span style="color: black;">&#125;</span>
&nbsp;
QString ComCpp::txt<span style="color: black;">&#40;</span><span style="color: black;">&#41;</span><span style="color: black;">&#123;</span>
    QString r = <span style="color: #FF0000;">&quot;You have clicked on QML Button&quot;</span>;
    <span style="color: #0000ff;">return</span> r;
<span style="color: black;">&#125;</span></pre></td></tr></table></pre>
</div><br />
Vous n'avez plus qu'à tester votre application. En théorie un clic sur le bouton doit faire le travail attendu... Évidemment, il n'est pas nécessaire de passer par du C++ pour faire ceci, mais cela vous montre le principe.<br />
<br />
Bonne lecture, à bientôt et n'hésitez pas à laisser vos commentaires.<br />
<br />
++<br />
<br />
J</blockquote>

]]></content:encoded>
			<dc:creator>Jiyuu</dc:creator>
			<guid isPermaLink="true">https://www.developpez.net/forums/blogs/135545-jiyuu/b757/interaction-entre-cpp-qml-premiere-methode-facilite/</guid>
		</item>
		<item>
			<title>Rendu des composants dans Qt Quick 2.x</title>
			<link>https://www.developpez.net/forums/blogs/135545-jiyuu/b559/rendu-composants-qt-quick-2-x/</link>
			<pubDate>Sat, 13 Jun 2015 17:00:54 GMT</pubDate>
			<description>Vous avez peut-être remarqué...</description>
			<content:encoded><![CDATA[<blockquote class="blogcontent restore">Vous avez peut-être remarqué que naturellement le rendu entre un composant Text (Qt Quick 2.x) et son homologue dans Qt Quick Controls 1.x, c'est à dire le Label est différent.<br />
<br />
En ce qui me concerne je préfère celui du Label. Travaillant actuellement sur un projet où je ne souhaite pas utiliser les Qt Quick Controls, j'ai décidé de prendre le taureau (enfin ... le bébé taureau) par les cornes et trouver d'où venait cette différence.<br />
<br />
Voici un petit bout de code qui met en évidence les différences et la manière d'arriver à mes fins :<br />
<div class="bbcode_container">
	<table width="100%" border="0" cellspacing="0" cellpadding="0"><tr>
	<td style="border: 0; padding: 0; text-align: left">Code qml :</td>
	<td style="border: 0; padding: 0; text-align: right"><a href="#" onclick="return ano_selectionnerCode(this);">Sélectionner tout</a> -
	<a href="#" onclick="return ano_etendreCode(this);">Visualiser dans une fenêtre à part</a></td></tr></table>
	<pre class="bbcode_code" style="height:204px;"><table cellspacing="0" cellpadding="0"><tr><td valign="top" width="33"><div style="border: 1px dashed gray; padding-left: 5px; padding-right: 5px; margin-right: 5px; text-align: right; font-family: monospace">1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br />22<br />23<br />24<br />25<br />26<br />27<br />28<br />29<br />30<br />31<br />32<br />33<br />34<br />35<br />36<br />37<br />38<br />39<br />40<br />41<br />42<br />43<br />44<br />45<br />46<br />47<br />48<br />49<br />50<br />51<br />52<br />53<br />54<br />55<br />56<br />57<br />58<br />59<br />60<br />61<br />62<br />63<br />64<br />65<br />66<br />67<br />68<br />69<br />70<br />71<br />72<br />73<br />74<br />75<br />76<br />77<br />78<br />79<br />80<br />81<br />82<br />83<br /></div></td><td valign="top"><pre style="margin: 0"><span style="color: #0000ff;">import</span> QtQuick <span style="color: #cc66cc;">2.4</span>
<span style="color: #0000ff;">import</span> QtQuick.Controls <span style="color: #cc66cc;">1.3</span>
&nbsp;
<span style="color: #0080ff;">Rectangle</span> <span style="color: black;">&#123;</span>
    <span style="color: #970009;">width</span>: <span style="color: #cc66cc;">800</span>
    <span style="color: #970009;">height</span>: <span style="color: #cc66cc;">300</span>
&nbsp;
    <span style="color: #0000ff;">property</span> <span style="color: #0000ff;">string</span> <span style="color: #970009;">testText</span>: <span style="color: #FF0000;">&quot;Ceci est un TEST de Text&quot;</span>
    <span style="color: #0000ff;">property</span> <span style="color: #0000ff;">string</span> <span style="color: #970009;">testLabel</span>: <span style="color: #FF0000;">&quot;Ceci est un TEST de Label&quot;</span>
&nbsp;
    <span style="color: #0080ff;">Text</span><span style="color: black;">&#123;</span>
        <span style="color: #970009;">id</span>: txt
        <span style="color: #970009;">anchors.horizontalCenter</span>: parent.horizontalCenter
        <span style="color: #970009;">anchors.top</span>: parent.top
        <span style="color: #970009;">text</span>: testText
&nbsp;
    <span style="color: black;">&#125;</span>
    <span style="color: #0080ff;">Label</span><span style="color: black;">&#123;</span>
        <span style="color: #970009;">id</span>: label
        <span style="color: #970009;">anchors.horizontalCenter</span>: parent.horizontalCenter
        <span style="color: #970009;">anchors.top</span>: txt.bottom
        <span style="color: #970009;">text</span>: testLabel
    <span style="color: black;">&#125;</span>
    <span style="color: #0080ff;">Rectangle</span><span style="color: black;">&#123;</span>
        <span style="color: #970009;">id</span>: <span style="color: #0000ff;">rect</span>
        <span style="color: #970009;">anchors.horizontalCenter</span>: parent.horizontalCenter
        <span style="color: #970009;">anchors.top</span>: label.bottom
        <span style="color: #970009;">height</span>: <span style="color: #cc66cc;">30</span>; <span style="color: #970009;">width</span>: <span style="color: #cc66cc;">30</span>
    <span style="color: black;">&#125;</span>
&nbsp;
    <span style="color: #0080ff;">Row</span><span style="color: black;">&#123;</span>
        <span style="color: #970009;">id</span>: row
        <span style="color: #970009;">anchors.horizontalCenter</span>: parent.horizontalCenter
        <span style="color: #970009;">anchors.top</span>: <span style="color: #0000ff;">rect</span>.bottom
        <span style="color: #970009;">spacing</span>: <span style="color: #cc66cc;">100</span>
&nbsp;
        <span style="color: #0080ff;">Text</span><span style="color: black;">&#123;</span>
            <span style="color: #970009;">text</span>: <span style="color: #FF0000;">&quot;D&eacute;tail composant Text :</span>
<span style="color: #FF0000;">Style : &quot;</span> +txt.style +<span style="color: #FF0000;">&quot;</span>
<span style="color: #FF0000;">Font : &quot;</span> + txt.<span style="color: #0000ff;">font</span>.family+<span style="color: #FF0000;">&quot;</span>
<span style="color: #FF0000;">Color : &quot;</span>+txt.<span style="color: #0000ff;">color</span>+<span style="color: #FF0000;">&quot;</span>
<span style="color: #FF0000;">Gras : &quot;</span>+txt.<span style="color: #0000ff;">font</span>.bold+<span style="color: #FF0000;">&quot;</span>
<span style="color: #FF0000;">Pixel : &quot;</span>+txt.<span style="color: #0000ff;">font</span>.pixelSize+<span style="color: #FF0000;">&quot;</span>
<span style="color: #FF0000;">Size : &quot;</span>+txt.<span style="color: #0000ff;">font</span>.pointSize+<span style="color: #FF0000;">&quot;</span>
<span style="color: #FF0000;">Render : &quot;</span>+txt.renderType+<span style="color: #FF0000;">&quot;</span>
<span style="color: #FF0000;">Format : &quot;</span>+txt.textFormat+<span style="color: #FF0000;">&quot;</span>
<span style="color: #FF0000;">Antialising : &quot;</span>+txt.antialiasing
&nbsp;
        <span style="color: black;">&#125;</span>
        <span style="color: #0080ff;">Label</span><span style="color: black;">&#123;</span>
            <span style="color: #970009;">text</span>: <span style="color: #FF0000;">&quot;D&eacute;tail composant Label :</span>
<span style="color: #FF0000;">Style : &quot;</span> +label.style +<span style="color: #FF0000;">&quot;</span>
<span style="color: #FF0000;">Font : &quot;</span> + label.<span style="color: #0000ff;">font</span>.family+<span style="color: #FF0000;">&quot;</span>
<span style="color: #FF0000;">Color : &quot;</span>+label.<span style="color: #0000ff;">color</span>+<span style="color: #FF0000;">&quot;</span>
<span style="color: #FF0000;">Gras : &quot;</span>+label.<span style="color: #0000ff;">font</span>.bold+<span style="color: #FF0000;">&quot;</span>
<span style="color: #FF0000;">Pixel : &quot;</span>+label.<span style="color: #0000ff;">font</span>.pixelSize+<span style="color: #FF0000;">&quot;</span>
<span style="color: #FF0000;">Size : &quot;</span>+label.<span style="color: #0000ff;">font</span>.pointSize+<span style="color: #FF0000;">&quot;</span>
<span style="color: #FF0000;">Render : &quot;</span>+label.renderType+<span style="color: #FF0000;">&quot;</span>
<span style="color: #FF0000;">Format : &quot;</span>+label.textFormat+<span style="color: #FF0000;">&quot;</span>
<span style="color: #FF0000;">Antialising : &quot;</span>+label.antialiasing
        <span style="color: black;">&#125;</span>
    <span style="color: black;">&#125;</span>
            <span style="color: #0080ff;">Rectangle</span><span style="color: black;">&#123;</span>
                <span style="color: #970009;">id</span>: rect1
                <span style="color: #970009;">anchors.horizontalCenter</span>: parent.horizontalCenter
                <span style="color: #970009;">anchors.top</span>: row.bottom
                <span style="color: #970009;">height</span>: <span style="color: #cc66cc;">30</span>; <span style="color: #970009;">width</span>: <span style="color: #cc66cc;">30</span>
            <span style="color: black;">&#125;</span>
            <span style="color: #0080ff;">Text</span><span style="color: black;">&#123;</span>
                <span style="color: #970009;">id</span>: txt1
                <span style="color: #970009;">anchors.horizontalCenter</span>: parent.horizontalCenter
                <span style="color: #970009;">anchors.top</span>: rect1.bottom
                <span style="color: #970009;">text</span>: testText + <span style="color: #FF0000;">&quot; modifi&eacute;&quot;</span>
                <span style="color: #970009;">renderType</span>: <span style="color: #0080ff;">Text</span>.NativeRendering
            <span style="color: black;">&#125;</span>
&nbsp;
            <span style="color: #0080ff;">Label</span><span style="color: black;">&#123;</span>
                <span style="color: #970009;">id</span>: label1
                <span style="color: #970009;">anchors.horizontalCenter</span>: parent.horizontalCenter
                <span style="color: #970009;">anchors.top</span>: txt1.bottom
                <span style="color: #970009;">text</span>: testLabel
            <span style="color: black;">&#125;</span>
<span style="color: black;">&#125;</span></pre></td></tr></table></pre>
</div><br />
Rien d'exceptionnel mais comme je voulais vraiment régler ce problème j'en profite pour mettre ceci ici ;)<br />
<br />
Bon WE à tous.<br />
<br />
<br />
J</blockquote>

]]></content:encoded>
			<dc:creator>Jiyuu</dc:creator>
			<guid isPermaLink="true">https://www.developpez.net/forums/blogs/135545-jiyuu/b559/rendu-composants-qt-quick-2-x/</guid>
		</item>
		<item>
			<title>Utilisation de QML pour lire une musique et/ou un film</title>
			<link>https://www.developpez.net/forums/blogs/135545-jiyuu/b537/utilisation-qml-lire-musique-film/</link>
			<pubDate>Mon, 01 Jun 2015 12:15:14 GMT</pubDate>
			<description>:salut:, 
 
Voici un code...</description>
			<content:encoded><![CDATA[<blockquote class="blogcontent restore">:salut:,<br />
<br />
Voici un code très rapide permettant de lancer une musique et/ou un film en QML :<br />
<div class="bbcode_container">
	<table width="100%" border="0" cellspacing="0" cellpadding="0"><tr>
	<td style="border: 0; padding: 0; text-align: left">Code qml :</td>
	<td style="border: 0; padding: 0; text-align: right"><a href="#" onclick="return ano_selectionnerCode(this);">Sélectionner tout</a> -
	<a href="#" onclick="return ano_etendreCode(this);">Visualiser dans une fenêtre à part</a></td></tr></table>
	<pre class="bbcode_code" style="height:204px;"><table cellspacing="0" cellpadding="0"><tr><td valign="top" width="33"><div style="border: 1px dashed gray; padding-left: 5px; padding-right: 5px; margin-right: 5px; text-align: right; font-family: monospace">1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br />22<br />23<br />24<br />25<br />26<br />27<br />28<br />29<br />30<br />31<br />32<br />33<br />34<br />35<br />36<br />37<br />38<br />39<br />40<br />41<br />42<br />43<br />44<br />45<br /></div></td><td valign="top"><pre style="margin: 0"><span style="color: #0000ff;">import</span> QtQuick <span style="color: #cc66cc;">2.4</span>
<span style="color: #0000ff;">import</span> QtMultimedia <span style="color: #cc66cc;">5.0</span>
<span style="color: #0000ff;">import</span> QtQuick.Controls <span style="color: #cc66cc;">1.3</span>
<span style="color: #0000ff;">import</span> QtQuick.Layouts <span style="color: #cc66cc;">1.1</span>  <span style="color: #808080;">// Histoire de placer facilement mes composants.</span>
&nbsp;
<span style="color: #0080ff;">ApplicationWindow</span> <span style="color: black;">&#123;</span>
    <span style="color: #970009;">width</span> : <span style="color: #cc66cc;">800</span>
    <span style="color: #970009;">height</span> : <span style="color: #cc66cc;">600</span>
    <span style="color: #0080ff;">GridLayout</span> <span style="color: black;">&#123;</span>
        <span style="color: #970009;">id</span>: grid
        <span style="color: #970009;">anchors.fill</span>: parent
        <span style="color: #970009;">columns</span> :<span style="color: #cc66cc;">2</span>
        <span style="color: #0080ff;">Button</span> <span style="color: black;">&#123;</span>
            <span style="color: #970009;">text</span>: <span style="color: #FF0000;">&quot;Lancer la musique&quot;</span>
            <span style="color: #970009;">onClicked</span>: playMusic.play<span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
            L<span style="color: #970009;">ayout.fillWidth</span>: <span style="color: #339933;">true</span>
        <span style="color: black;">&#125;</span>
        <span style="color: #0080ff;">Button</span> <span style="color: black;">&#123;</span>
            <span style="color: #970009;">text</span>: <span style="color: #FF0000;">&quot;Lancer le Film&quot;</span>
            <span style="color: #970009;">onClicked</span>: video.play<span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
            L<span style="color: #970009;">ayout.fillWidth</span>: <span style="color: #339933;">true</span>
        <span style="color: black;">&#125;</span>
&nbsp;
        <span style="color: #0080ff;">Video</span> <span style="color: black;">&#123;</span>
            <span style="color: #970009;">id</span>: video
            <span style="color: #970009;">source</span>: <span style="color: #FF0000;">&quot;/home/charlie/Movies/Taken.avi&quot;</span>
            L<span style="color: #970009;">ayout.fillHeight</span>: <span style="color: #339933;">true</span>
            L<span style="color: #970009;">ayout.fillWidth</span>: <span style="color: #339933;">true</span>
            L<span style="color: #970009;">ayout.columnSpan</span>: grid.columns
&nbsp;
            <span style="color: #808080;">// au cas o&ugrave; l'on souhaite lancer la vid&eacute;o en cliquant sur l'espace r&eacute;serv&eacute; &agrave; sa lecture.</span>
            <span style="color: #0080ff;">MouseArea</span> <span style="color: black;">&#123;</span>
                <span style="color: #970009;">anchors.fill</span>: parent
                <span style="color: #970009;">onClicked</span>:&nbsp;<span class="br0">&#123;</span></span>
<span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; video.<span style="color: #0080ff;">play</span><span class="br0">&#40;</span><span class="br0">&#41;</span></span>
<span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span>
            <span style="color: black;">&#125;</span>
        <span style="color: black;">&#125;</span>
&nbsp;
        <span style="color: #0080ff;">Audio</span> <span style="color: black;">&#123;</span>
            <span style="color: #970009;">id</span>: playMusic
            <span style="color: #970009;">source</span>: <span style="color: #FF0000;">&quot;cosmo.mp3&quot;</span>
        <span style="color: black;">&#125;</span>
    <span style="color: black;">&#125;</span>
<span style="color: black;">&#125;</span></pre></td></tr></table></pre>
</div><br />
et le code Python qui va bien:<br />
<div class="bbcode_container">
	<table width="100%" border="0" cellspacing="0" cellpadding="0"><tr>
	<td style="border: 0; padding: 0; text-align: left">Code python :</td>
	<td style="border: 0; padding: 0; text-align: right"><a href="#" onclick="return ano_selectionnerCode(this);">Sélectionner tout</a> -
	<a href="#" onclick="return ano_etendreCode(this);">Visualiser dans une fenêtre à part</a></td></tr></table>
	<pre class="bbcode_code" style="height:204px;"><table cellspacing="0" cellpadding="0"><tr><td valign="top" width="33"><div style="border: 1px dashed gray; padding-left: 5px; padding-right: 5px; margin-right: 5px; text-align: right; font-family: monospace">1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br /></div></td><td valign="top"><pre style="margin: 0"><span style="color: #808080;">#!/usr/bin/env python</span>
<span style="color: #808080;"># -*- coding: utf-8 -*-</span>
&nbsp;
<span style="color: #0000ff;">import</span> sys, platform
<span style="color: #0000ff;">from</span> PyQt5.QtWidgets <span style="color: #0000ff;">import</span> QApplication
<span style="color: #0000ff;">from</span> PyQt5.QtQml <span style="color: #0000ff;">import</span> QQmlApplicationEngine, QQmlComponent
&nbsp;
&nbsp;
<span style="color: #0000ff;">if</span> <span style="color: #0080ff;">__name__</span> == <span style="color: #FF0000;">&quot;__main__&quot;</span>:
    app = QApplication<span class="br0">&#40;</span>sys.argv<span class="br0">&#41;</span>
    engine = QQmlApplicationEngine<span class="br0">&#40;</span><span class="br0">&#41;</span>
    engine.load<span class="br0">&#40;</span><span style="color: #FF0000;">'test.qml'</span><span class="br0">&#41;</span>
    win = engine.rootObjects<span class="br0">&#40;</span><span class="br0">&#41;</span><span class="br0">&#91;</span><span style="color: #cc66cc;">0</span><span class="br0">&#93;</span>
    win.show<span class="br0">&#40;</span><span class="br0">&#41;</span>
    sys.exit<span class="br0">&#40;</span>app.<span style="color: #0000ff;">exec</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="br0">&#41;</span></pre></td></tr></table></pre>
</div><br />
ou la version C++ :<br />
<div class="bbcode_container">
	<table width="100%" border="0" cellspacing="0" cellpadding="0"><tr>
	<td style="border: 0; padding: 0; text-align: left">Code c++ :</td>
	<td style="border: 0; padding: 0; text-align: right"><a href="#" onclick="return ano_selectionnerCode(this);">Sélectionner tout</a> -
	<a href="#" onclick="return ano_etendreCode(this);">Visualiser dans une fenêtre à part</a></td></tr></table>
	<pre class="bbcode_code" style="height:204px;"><table cellspacing="0" cellpadding="0"><tr><td valign="top" width="33"><div style="border: 1px dashed gray; padding-left: 5px; padding-right: 5px; margin-right: 5px; text-align: right; font-family: monospace">1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br /></div></td><td valign="top"><pre style="margin: 0"><span style="color: #339933;">#include</span><span style="color: #FF0000;"> &lt;QApplication&gt;</span>
<span style="color: #339933;">#include</span><span style="color: #FF0000;"> &lt;QQmlApplicationEngine&gt;</span>
<span style="color: #339933;">#include</span><span style="color: #FF0000;"> &lt;QQmlContext&gt;</span>
&nbsp;
&nbsp;
<span style="color: #0000ff;">int</span> main<span style="color: black;">&#40;</span><span style="color: #0000ff;">int</span> argc, <span style="color: #0000ff;">char</span> *argv<span style="color: black;">&#91;</span><span style="color: black;">&#93;</span><span style="color: black;">&#41;</span>
<span style="color: black;">&#123;</span>
    QApplication app<span style="color: black;">&#40;</span>argc, argv<span style="color: black;">&#41;</span>;
&nbsp;
    QQmlApplicationEngine engine;
    engine.load<span style="color: black;">&#40;</span>QUrl<span style="color: black;">&#40;</span>QStringLiteral<span style="color: black;">&#40;</span><span style="color: #FF0000;">&quot;qrc:/test.qml&quot;</span><span style="color: black;">&#41;</span><span style="color: black;">&#41;</span><span style="color: black;">&#41;</span>;
&nbsp;
    <span style="color: #0000ff;">return</span> app.exec<span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>;
&nbsp;
<span style="color: black;">&#125;</span></pre></td></tr></table></pre>
</div><br />
<br />
Déconcertant de simplicité !!!! :mouarf: ;)</blockquote>

]]></content:encoded>
			<dc:creator>Jiyuu</dc:creator>
			<guid isPermaLink="true">https://www.developpez.net/forums/blogs/135545-jiyuu/b537/utilisation-qml-lire-musique-film/</guid>
		</item>
		<item>
			<title><![CDATA[[QML] Comment créer un calendrier en popup]]></title>
			<link>https://www.developpez.net/forums/blogs/135545-jiyuu/b440/qml-creer-calendrier-popup/</link>
			<pubDate>Tue, 14 Apr 2015 12:21:52 GMT</pubDate>
			<description>Voici un code permettant...</description>
			<content:encoded><![CDATA[<blockquote class="blogcontent restore">Voici un code permettant d'afficher en popup un calendrier et de retourner la date sélectionnée dans le format voulu :<br />
<br />
<div class="bbcode_container">
	<table width="100%" border="0" cellspacing="0" cellpadding="0"><tr>
	<td style="border: 0; padding: 0; text-align: left">Code qml :</td>
	<td style="border: 0; padding: 0; text-align: right"><a href="#" onclick="return ano_selectionnerCode(this);">Sélectionner tout</a> -
	<a href="#" onclick="return ano_etendreCode(this);">Visualiser dans une fenêtre à part</a></td></tr></table>
	<pre class="bbcode_code" style="height:204px;"><table cellspacing="0" cellpadding="0"><tr><td valign="top" width="33"><div style="border: 1px dashed gray; padding-left: 5px; padding-right: 5px; margin-right: 5px; text-align: right; font-family: monospace">1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br />22<br />23<br /></div></td><td valign="top"><pre style="margin: 0"><span style="color: #0000ff;">import</span> QtQuick <span style="color: #cc66cc;">2.4</span>
<span style="color: #0000ff;">import</span> QtQuick.Controls <span style="color: #cc66cc;">1.3</span>
<span style="color: #0000ff;">import</span> QtQuick.Dialogs <span style="color: #cc66cc;">1.2</span>
&nbsp;
<span style="color: #0080ff;">Dialog</span> <span style="color: black;">&#123;</span>
    <span style="color: #970009;">id</span>: dateDialog
    <span style="color: #970009;">width</span> : <span style="color: #cc66cc;">400</span>
    <span style="color: #970009;">height</span> : <span style="color: #cc66cc;">350</span>
    <span style="color: #970009;">visible</span>: <span style="color: #339933;">true</span>
    <span style="color: #970009;">title</span>: <span style="color: #FF0000;">&quot;S&eacute;lectionner une date&quot;</span>
    <span style="color: #970009;">standardButtons</span>: StandardButton.Ok | StandardButton.Cancel
&nbsp;
    <span style="color: #970009;">onAccepted</span>: console.log<span style="color: black;">&#40;</span><span style="color: #FF0000;">&quot;Date s&eacute;lectionn&eacute;e : &quot;</span>,<span style="color: #0080ff;">Qt</span>.formatDate<span style="color: black;">&#40;</span>calendar.selectedDate, <span style="color: #FF0000;">&quot;dd/MM/yyyy&quot;</span><span style="color: black;">&#41;</span><span style="color: black;">&#41;</span>
&nbsp;
    <span style="color: #0080ff;">Calendar</span> <span style="color: black;">&#123;</span>
        <span style="color: #970009;">id</span>: calendar
        <span style="color: #970009;">weekNumbersVisible</span>: <span style="color: #339933;">true</span>
        <span style="color: #970009;">width</span> : <span style="color: #cc66cc;">375</span>
        <span style="color: #970009;">height</span> : <span style="color: #cc66cc;">295</span>
        <span style="color: #970009;">onDoubleClicked</span>: dateDialog.click<span style="color: black;">&#40;</span>StandardButton.Ok<span style="color: black;">&#41;</span>
&nbsp;
    <span style="color: black;">&#125;</span>
<span style="color: black;">&#125;</span></pre></td></tr></table></pre>
</div></blockquote>

]]></content:encoded>
			<dc:creator>Jiyuu</dc:creator>
			<guid isPermaLink="true">https://www.developpez.net/forums/blogs/135545-jiyuu/b440/qml-creer-calendrier-popup/</guid>
		</item>
		<item>
			<title><![CDATA[Création d'un menu contextuel (clic droit) en QML]]></title>
			<link>https://www.developpez.net/forums/blogs/135545-jiyuu/b388/creation-d-menu-contextuel-clic-droit-qml/</link>
			<pubDate>Fri, 27 Mar 2015 17:30:06 GMT</pubDate>
			<description>:salut: 
 
Voici un morceau...</description>
			<content:encoded><![CDATA[<blockquote class="blogcontent restore">:salut:<br />
<br />
Voici un morceau de code qui permet de créer un menu contextuel en QML. Le principe est simple :<br />
<ul><li style="">Suite à un clic droit sur une zone définie on rend visible une fenêtre sans bordure ;</li><li style="">lors de la sélection d'une action ou en cas de sortie de la zone du menu contextuel,  on rend &quot;invisble&quot; celui-ci</li></ul><br />
<br />
<br />
<div class="bbcode_container">
	<table width="100%" border="0" cellspacing="0" cellpadding="0"><tr>
	<td style="border: 0; padding: 0; text-align: left">Code qml :</td>
	<td style="border: 0; padding: 0; text-align: right"><a href="#" onclick="return ano_selectionnerCode(this);">Sélectionner tout</a> -
	<a href="#" onclick="return ano_etendreCode(this);">Visualiser dans une fenêtre à part</a></td></tr></table>
	<pre class="bbcode_code" style="height:204px;"><table cellspacing="0" cellpadding="0"><tr><td valign="top" width="33"><div style="border: 1px dashed gray; padding-left: 5px; padding-right: 5px; margin-right: 5px; text-align: right; font-family: monospace">1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br />22<br />23<br />24<br />25<br />26<br />27<br />28<br />29<br />30<br />31<br />32<br />33<br />34<br />35<br />36<br />37<br />38<br />39<br />40<br />41<br />42<br />43<br />44<br />45<br />46<br />47<br />48<br />49<br />50<br />51<br />52<br />53<br />54<br />55<br />56<br />57<br />58<br />59<br />60<br />61<br />62<br />63<br />64<br />65<br />66<br />67<br />68<br /></div></td><td valign="top"><pre style="margin: 0"><span style="color: #0000ff;">import</span> QtQuick <span style="color: #cc66cc;">2.4</span>
<span style="color: #0000ff;">import</span> QtQuick.Controls <span style="color: #cc66cc;">1.3</span>
<span style="color: #0000ff;">import</span> QtQuick.<span style="color: #0080ff;">Window</span> <span style="color: #cc66cc;">2.2</span>
&nbsp;
<span style="color: #0080ff;">Window</span> <span style="color: black;">&#123;</span>
    <span style="color: #970009;">id</span>: view
    <span style="color: #970009;">height</span> : <span style="color: #cc66cc;">200</span>
    <span style="color: #970009;">width</span> : <span style="color: #cc66cc;">300</span>
    <span style="color: #970009;">x</span>: <span style="color: #cc66cc;">100</span>
    <span style="color: #970009;">y</span>: <span style="color: #cc66cc;">100</span>
&nbsp;
&nbsp;
    <span style="color: #0080ff;">Label</span> <span style="color: black;">&#123;</span>
        <span style="color: #970009;">text</span>: <span style="color: #FF0000;">&quot;test&quot;</span>
        <span style="color: #0080ff;">MouseArea</span> <span style="color: black;">&#123;</span>
            <span style="color: #970009;">id</span>: mouseArea
            <span style="color: #970009;">anchors.fill</span>: parent
            <span style="color: #970009;">acceptedButtons</span>: <span style="color: #0080ff;">Qt</span>.LeftButton | <span style="color: #0080ff;">Qt</span>.RightButton
            <span style="color: #970009;">onClicked</span>:&nbsp;<span class="br0">&#123;</span></span>
<span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">if</span> <span class="br0">&#40;</span>mouse.<span style="color: #0080ff;">button</span> === Qt.RightButton<span class="br0">&#41;</span><span class="br0">&#123;</span></span>
<span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; contextMenu.visible = <span style="color: #339933;">true</span></span>
<span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; contextMenu.y = view.y + mouseY</span>
<span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; contextMenu.x = view.x + mouseX + <span style="color: #cc66cc;">15</span></span>
<span>&nbsp;</span>
<span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span></span>
<span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span>
        <span style="color: black;">&#125;</span>
    <span style="color: black;">&#125;</span>
    <span style="color: #0080ff;">Window</span> <span style="color: black;">&#123;</span>
        <span style="color: #970009;">id</span>: contextMenu
        <span style="color: #970009;">visible</span>: <span style="color: #339933;">false</span>
        <span style="color: #970009;">height</span>: <span style="color: #cc66cc;">100</span>
        <span style="color: #970009;">width</span>: <span style="color: #cc66cc;">150</span>
        <span style="color: #970009;">flags</span>: <span style="color: #0080ff;">Qt</span>.FramelessWindowHint
        <span style="color: #970009;">color</span>: <span style="color: #FF0000;">&quot;lightgray&quot;</span>
&nbsp;
        <span style="color: #0080ff;">MouseArea</span> <span style="color: black;">&#123;</span>
            <span style="color: #970009;">anchors.fill</span>: parent
            <span style="color: #970009;">hoverEnabled</span>: <span style="color: #339933;">true</span>
            <span style="color: #970009;">onExited</span>: contextMenu.visible = <span style="color: #339933;">false</span>
        <span style="color: black;">&#125;</span>
&nbsp;
        <span style="color: #0080ff;">Column</span><span style="color: black;">&#123;</span>
            <span style="color: #970009;">anchors.fill</span>: parent
&nbsp;
            <span style="color: #0080ff;">Label</span> <span style="color: black;">&#123;</span>
                <span style="color: #970009;">text</span>: <span style="color: #FF0000;">&quot;Action 1&quot;</span>
                <span style="color: #0080ff;">MouseArea</span> <span style="color: black;">&#123;</span>
                    <span style="color: #970009;">anchors.fill</span>: parent
                    <span style="color: #970009;">onClicked</span> :&nbsp;<span class="br0">&#123;</span></span>
<span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; console.<span style="color: #0080ff;">log</span><span class="br0">&#40;</span><span style="color: #FF0000;">&quot;Vous avez cliqu&eacute; sur Action 1&quot;</span><span class="br0">&#41;</span></span>
<span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; contextMenu.visible = <span style="color: #339933;">false</span></span>
<span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span>
                <span style="color: black;">&#125;</span>
            <span style="color: black;">&#125;</span>
            <span style="color: #0080ff;">Label</span> <span style="color: black;">&#123;</span>
                <span style="color: #970009;">text</span>: <span style="color: #FF0000;">&quot;Action 2&quot;</span>
                <span style="color: #0080ff;">MouseArea</span> <span style="color: black;">&#123;</span>
                    <span style="color: #970009;">anchors.fill</span>: parent
                    <span style="color: #970009;">onClicked</span> :&nbsp;<span class="br0">&#123;</span></span>
<span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; console.<span style="color: #0080ff;">log</span><span class="br0">&#40;</span><span style="color: #FF0000;">&quot;Vous avez cliqu&eacute; sur Action 2&quot;</span><span class="br0">&#41;</span></span>
<span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; contextMenu.visible = <span style="color: #339933;">false</span></span>
<span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span>
                <span style="color: black;">&#125;</span>
            <span style="color: black;">&#125;</span>
        <span style="color: black;">&#125;</span>
    <span style="color: black;">&#125;</span>
<span style="color: black;">&#125;</span></pre></td></tr></table></pre>
</div></blockquote>

]]></content:encoded>
			<dc:creator>Jiyuu</dc:creator>
			<guid isPermaLink="true">https://www.developpez.net/forums/blogs/135545-jiyuu/b388/creation-d-menu-contextuel-clic-droit-qml/</guid>
		</item>
		<item>
			<title><![CDATA[Connexion et Gestion d'une base de données en QML (act I)]]></title>
			<link>https://www.developpez.net/forums/blogs/135545-jiyuu/b146/connexion-gestion-d-base-donnees-qml-act-i/</link>
			<pubDate>Mon, 19 Jan 2015 14:46:40 GMT</pubDate>
			<description>:salut: à tous, 
 
Voici un...</description>
			<content:encoded><![CDATA[<blockquote class="blogcontent restore">:salut: à tous,<br />
<br />
Voici un morceau de code facilitant la connexion et la gestion à une base de données en QML.<br />
J'utilise LocalStorage (qui a ses qualités et ses défauts), et j'ai commencé à créer quelques fonctions simples mais quasi indispensables.<br />
<br />
<div class="bbcode_container">
	<table width="100%" border="0" cellspacing="0" cellpadding="0"><tr>
	<td style="border: 0; padding: 0; text-align: left">Code qml :</td>
	<td style="border: 0; padding: 0; text-align: right"><a href="#" onclick="return ano_selectionnerCode(this);">Sélectionner tout</a> -
	<a href="#" onclick="return ano_etendreCode(this);">Visualiser dans une fenêtre à part</a></td></tr></table>
	<pre class="bbcode_code" style="height:204px;"><table cellspacing="0" cellpadding="0"><tr><td valign="top" width="40"><div style="border: 1px dashed gray; padding-left: 5px; padding-right: 5px; margin-right: 5px; text-align: right; font-family: monospace">1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br />22<br />23<br />24<br />25<br />26<br />27<br />28<br />29<br />30<br />31<br />32<br />33<br />34<br />35<br />36<br />37<br />38<br />39<br />40<br />41<br />42<br />43<br />44<br />45<br />46<br />47<br />48<br />49<br />50<br />51<br />52<br />53<br />54<br />55<br />56<br />57<br />58<br />59<br />60<br />61<br />62<br />63<br />64<br />65<br />66<br />67<br />68<br />69<br />70<br />71<br />72<br />73<br />74<br />75<br />76<br />77<br />78<br />79<br />80<br />81<br />82<br />83<br />84<br />85<br />86<br />87<br />88<br />89<br />90<br />91<br />92<br />93<br />94<br />95<br />96<br />97<br />98<br />99<br />100<br />101<br />102<br />103<br />104<br />105<br />106<br />107<br />108<br />109<br />110<br />111<br />112<br />113<br />114<br />115<br />116<br />117<br />118<br />119<br />120<br />121<br />122<br />123<br />124<br />125<br />126<br />127<br />128<br />129<br />130<br />131<br />132<br />133<br /></div></td><td valign="top"><pre style="margin: 0"><span style="color: #0000ff;">import</span> QtQuick <span style="color: #cc66cc;">2.4</span>
<span style="color: #0000ff;">import</span> QtQuick.LocalStorage <span style="color: #cc66cc;">2.0</span>
&nbsp;
<span style="color: #0080ff;">Item</span> <span style="color: black;">&#123;</span>
    <span style="color: #008025;">/*Propri&eacute;t&eacute; de l'item &agrave; rensigner */</span>
    <span style="color: #0000ff;">property</span> <span style="color: #0000ff;">var</span> <span style="color: #970009;">db</span> : getDatabase<span style="color: black;">&#40;</span><span style="color: #FF0000;">&quot;QQmlExampleDB&quot;</span>, <span style="color: #FF0000;">&quot;1.0&quot;</span>, <span style="color: #FF0000;">&quot;The Example QML SQL!&quot;</span>, <span style="color: #cc66cc;">1000000</span><span style="color: black;">&#41;</span>
    <span style="color: #0000ff;">property</span> <span style="color: #0000ff;">string</span> <span style="color: #970009;">dbTable</span> : <span style="color: #FF0000;">&quot;Greeting&quot;</span>
&nbsp;
&nbsp;
&nbsp;
&nbsp;
    <span style="color: #008025;">/* Exemple de codes  */</span>
    <span style="color: #0000ff;">function</span> <span style="color: #0080ff;">printResult</span><span class="br0">&#40;</span>result<span class="br0">&#41;</span><span class="br0">&#123;</span></span>
<span>&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">for</span><span class="br0">&#40;</span><span style="color: #0000ff;">var</span> key <span style="color: #0000ff;">in</span> result<span class="br0">&#41;</span><span class="br0">&#123;</span></span>
<span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">var</span> dic = result<span class="br0">&#91;</span>key<span class="br0">&#93;</span></span>
<span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; console.<span style="color: #0080ff;">log</span><span class="br0">&#40;</span>key, dic.salutee, dic.salutation<span class="br0">&#41;</span></span>
<span>&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span></span>
<span>&nbsp;</span>
<span>&nbsp; &nbsp; <span class="br0">&#125;</span>
&nbsp;
    C<span style="color: #970009;">omponent.onCompleted</span>:&nbsp;<span class="br0">&#123;</span></span>
<span>&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0080ff;">createTable</span><span class="br0">&#40;</span><span style="color: #FF0000;">'salutation TEXT, salutee TEXT'</span><span class="br0">&#41;</span></span>
<span>&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0080ff;">insertValueByCol</span><span class="br0">&#40;</span><span class="br0">&#123;</span><span style="color: #FF0000;">&quot;salutee&quot;</span>:<span style="color: #FF0000;">&quot;Bob&quot;</span>, <span style="color: #FF0000;">&quot;salutation&quot;</span>:<span style="color: #FF0000;">&quot;hello&quot;</span><span class="br0">&#125;</span><span class="br0">&#41;</span></span>
<span>&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0080ff;">insertValueByCol</span><span class="br0">&#40;</span><span class="br0">&#123;</span><span style="color: #FF0000;">&quot;salutee&quot;</span>:<span style="color: #FF0000;">&quot;Bob&quot;</span>, <span style="color: #FF0000;">&quot;salutation&quot;</span>:<span style="color: #FF0000;">&quot;hello&quot;</span><span class="br0">&#125;</span><span class="br0">&#41;</span></span>
<span>&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0080ff;">insertValue</span><span class="br0">&#40;</span><span class="br0">&#91;</span><span style="color: #FF0000;">&quot;hello&quot;</span>,<span style="color: #FF0000;">&quot;Toto&quot;</span><span class="br0">&#93;</span><span class="br0">&#41;</span></span>
<span>&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0080ff;">insertValue</span><span class="br0">&#40;</span><span class="br0">&#91;</span><span style="color: #FF0000;">&quot;salut&quot;</span>,<span style="color: #FF0000;">&quot;Jiyuu&quot;</span><span class="br0">&#93;</span><span class="br0">&#41;</span></span>
<span>&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">var</span> newData = <span style="color: #0080ff;">getAll</span><span class="br0">&#40;</span><span class="br0">&#41;</span></span>
<span>&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">var</span> newData2 = <span style="color: #0080ff;">filter</span><span class="br0">&#40;</span><span style="color: #FF0000;">&quot;salutation = 'hello'&quot;</span><span class="br0">&#41;</span></span>
<span>&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0080ff;">printResult</span><span class="br0">&#40;</span>newData2<span class="br0">&#41;</span></span>
<span>&nbsp; &nbsp; <span class="br0">&#125;</span>
&nbsp;
&nbsp;
&nbsp;
    <span style="color: #008025;">/* Fonctions internes */</span>
    <span style="color: #0000ff;">function</span> <span style="color: #0080ff;">getDatabase</span><span class="br0">&#40;</span><span style="color: #0080ff;">name</span>, version, descriptif, taille<span class="br0">&#41;</span> <span class="br0">&#123;</span></span>
<span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #0000ff;">return</span> LocalStorage.<span style="color: #0080ff;">openDatabaseSync</span><span class="br0">&#40;</span><span style="color: #0080ff;">name</span>, version , descriptif, taille<span class="br0">&#41;</span>;</span>
<span>&nbsp; &nbsp; <span class="br0">&#125;</span>
&nbsp;
    <span style="color: #0000ff;">function</span> <span style="color: #0080ff;">createTable</span><span class="br0">&#40;</span>dbQuery<span class="br0">&#41;</span> <span class="br0">&#123;</span></span>
<span>&nbsp; &nbsp; &nbsp; &nbsp; db.<span style="color: #0080ff;">transaction</span><span class="br0">&#40;</span></span>
<span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">function</span><span class="br0">&#40;</span>tx<span class="br0">&#41;</span> <span class="br0">&#123;</span></span>
<span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; tx.<span style="color: #0080ff;">executeSql</span><span class="br0">&#40;</span><span style="color: #FF0000;">'CREATE TABLE IF NOT EXISTS '</span> +dbTable+ <span style="color: #FF0000;">' ('</span>+dbQuery+<span style="color: #FF0000;">')'</span><span class="br0">&#41;</span>;</span>
<span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span></span>
<span>&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#41;</span></span>
<span>&nbsp; &nbsp; <span class="br0">&#125;</span>
&nbsp;
    <span style="color: #0000ff;">function</span> <span style="color: #0080ff;">insertValueByCol</span><span class="br0">&#40;</span>dbDict<span class="br0">&#41;</span> <span class="br0">&#123;</span></span>
<span>&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">var</span> dbColumn = <span class="br0">&#91;</span><span class="br0">&#93;</span></span>
<span>&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">var</span> dbValue = <span class="br0">&#91;</span><span class="br0">&#93;</span></span>
<span>&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">var</span> nbVal = <span style="color: #FF0000;">''</span></span>
<span>&nbsp;</span>
<span>&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">for</span><span class="br0">&#40;</span><span style="color: #0000ff;">var</span> key <span style="color: #0000ff;">in</span> dbDict<span class="br0">&#41;</span> <span class="br0">&#123;</span></span>
<span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; dbColumn.<span style="color: #0080ff;">push</span><span class="br0">&#40;</span>key<span class="br0">&#41;</span></span>
<span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; dbValue.<span style="color: #0080ff;">push</span><span class="br0">&#40;</span>dbDict<span class="br0">&#91;</span>key<span class="br0">&#93;</span><span class="br0">&#41;</span></span>
<span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; nbVal += <span style="color: #FF0000;">'?,'</span></span>
<span>&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span></span>
<span>&nbsp;</span>
<span>&nbsp; &nbsp; &nbsp; &nbsp; nbVal = nbVal.<span style="color: #0080ff;">substring</span><span class="br0">&#40;</span><span style="color: #cc66cc;">0</span>, nbVal.<span style="color: #0080ff;">length</span> - <span style="color: #cc66cc;">1</span><span class="br0">&#41;</span>;</span>
<span>&nbsp; &nbsp; &nbsp; &nbsp; db.<span style="color: #0080ff;">transaction</span><span class="br0">&#40;</span></span>
<span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">function</span><span class="br0">&#40;</span>tx<span class="br0">&#41;</span> <span class="br0">&#123;</span></span>
<span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; tx.<span style="color: #0080ff;">executeSql</span><span class="br0">&#40;</span><span style="color: #FF0000;">'INSERT INTO '</span> +dbTable+<span style="color: #FF0000;">'('</span>+dbColumn+<span style="color: #FF0000;">')'</span>+ <span style="color: #FF0000;">' VALUES('</span>+nbVal+<span style="color: #FF0000;">')'</span>, dbValue<span class="br0">&#41;</span>;</span>
<span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span></span>
<span>&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#41;</span></span>
<span>&nbsp; &nbsp; <span class="br0">&#125;</span>
&nbsp;
    <span style="color: #0000ff;">function</span> <span style="color: #0080ff;">insertValue</span><span class="br0">&#40;</span>dbValue<span class="br0">&#41;</span> <span class="br0">&#123;</span></span>
<span>&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">var</span> nbVal = <span style="color: #FF0000;">''</span></span>
<span>&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">for</span><span class="br0">&#40;</span><span style="color: #0000ff;">var</span> i <span style="color: #0000ff;">in</span> dbValue<span class="br0">&#41;</span> <span class="br0">&#123;</span></span>
<span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; nbVal += <span style="color: #FF0000;">'?,'</span></span>
<span>&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span></span>
<span>&nbsp; &nbsp; &nbsp; &nbsp; nbVal = nbVal.<span style="color: #0080ff;">substring</span><span class="br0">&#40;</span><span style="color: #cc66cc;">0</span>, nbVal.<span style="color: #0080ff;">length</span> - <span style="color: #cc66cc;">1</span><span class="br0">&#41;</span>;</span>
<span>&nbsp; &nbsp; &nbsp; &nbsp; db.<span style="color: #0080ff;">transaction</span><span class="br0">&#40;</span></span>
<span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">function</span><span class="br0">&#40;</span>tx<span class="br0">&#41;</span> <span class="br0">&#123;</span></span>
<span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; tx.<span style="color: #0080ff;">executeSql</span><span class="br0">&#40;</span><span style="color: #FF0000;">'INSERT INTO '</span> +dbTable+ <span style="color: #FF0000;">' VALUES('</span>+nbVal+<span style="color: #FF0000;">')'</span>, dbValue<span class="br0">&#41;</span>;</span>
<span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span></span>
<span>&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#41;</span></span>
<span>&nbsp; &nbsp; <span class="br0">&#125;</span>
&nbsp;
    <span style="color: #0000ff;">function</span> <span style="color: #0080ff;">getAll</span><span class="br0">&#40;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span></span>
<span>&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">var</span> result</span>
<span>&nbsp; &nbsp; &nbsp; &nbsp; db.<span style="color: #0080ff;">transaction</span><span class="br0">&#40;</span></span>
<span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">function</span><span class="br0">&#40;</span>tx<span class="br0">&#41;</span> <span class="br0">&#123;</span></span>
<span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">var</span> rs = tx.<span style="color: #0080ff;">executeSql</span><span class="br0">&#40;</span><span style="color: #FF0000;">'SELECT * FROM '</span>+dbTable<span class="br0">&#41;</span>;</span>
<span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">var</span> info = tx.<span style="color: #0080ff;">executeSql</span><span class="br0">&#40;</span><span style="color: #FF0000;">'PRAGMA table_info('</span>+dbTable+<span style="color: #FF0000;">') '</span><span class="br0">&#41;</span></span>
<span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">var</span> col = <span class="br0">&#91;</span><span class="br0">&#93;</span></span>
<span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">var</span> r = <span class="br0">&#91;</span><span class="br0">&#93;</span></span>
<span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">for</span><span class="br0">&#40;</span><span style="color: #0000ff;">var</span> column = <span style="color: #cc66cc;">0</span>; column &lt; info.rows.<span style="color: #0080ff;">length</span>; column++<span class="br0">&#41;</span> <span class="br0">&#123;</span></span>
<span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; col.<span style="color: #0080ff;">push</span><span class="br0">&#40;</span>info.rows.<span style="color: #0080ff;">item</span><span class="br0">&#40;</span>column<span class="br0">&#41;</span>.<span style="color: #0080ff;">name</span><span class="br0">&#41;</span></span>
<span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span></span>
<span>&nbsp;</span>
<span>&nbsp;</span>
<span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">for</span><span class="br0">&#40;</span><span style="color: #0000ff;">var</span> i = <span style="color: #cc66cc;">0</span>; i &lt; rs.rows.<span style="color: #0080ff;">length</span>; i++<span class="br0">&#41;</span><span class="br0">&#123;</span></span>
<span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">var</span> dic = <span class="br0">&#123;</span><span class="br0">&#125;</span></span>
<span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">for</span><span class="br0">&#40;</span><span style="color: #0000ff;">var</span> key <span style="color: #0000ff;">in</span> col<span class="br0">&#41;</span> <span class="br0">&#123;</span></span>
<span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">var</span> keyDic = col<span class="br0">&#91;</span>key<span class="br0">&#93;</span></span>
<span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">var</span> valueDic = rs.rows.<span style="color: #0080ff;">item</span><span class="br0">&#40;</span>i<span class="br0">&#41;</span><span class="br0">&#91;</span>keyDic<span class="br0">&#93;</span></span>
<span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; dic<span class="br0">&#91;</span>keyDic<span class="br0">&#93;</span> = valueDic</span>
<span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span></span>
<span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; r.<span style="color: #0080ff;">push</span><span class="br0">&#40;</span>dic<span class="br0">&#41;</span></span>
<span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span></span>
<span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; result = r</span>
<span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span></span>
<span>&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#41;</span></span>
<span>&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">return</span> result</span>
<span>&nbsp; &nbsp; <span class="br0">&#125;</span>
    <span style="color: #0000ff;">function</span> <span style="color: #0080ff;">filter</span><span class="br0">&#40;</span>query<span class="br0">&#41;</span> <span class="br0">&#123;</span></span>
<span>&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">var</span> result</span>
<span>&nbsp; &nbsp; &nbsp; &nbsp; db.<span style="color: #0080ff;">transaction</span><span class="br0">&#40;</span></span>
<span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">function</span><span class="br0">&#40;</span>tx<span class="br0">&#41;</span> <span class="br0">&#123;</span></span>
<span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">var</span> rs = tx.<span style="color: #0080ff;">executeSql</span><span class="br0">&#40;</span><span style="color: #FF0000;">'SELECT * FROM '</span>+dbTable+<span style="color: #FF0000;">' WHERE '</span>+query<span class="br0">&#41;</span>;</span>
<span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">var</span> info = tx.<span style="color: #0080ff;">executeSql</span><span class="br0">&#40;</span><span style="color: #FF0000;">'PRAGMA table_info('</span>+dbTable+<span style="color: #FF0000;">') '</span><span class="br0">&#41;</span></span>
<span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">var</span> col = <span class="br0">&#91;</span><span class="br0">&#93;</span></span>
<span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">var</span> r = <span class="br0">&#91;</span><span class="br0">&#93;</span></span>
<span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">for</span><span class="br0">&#40;</span><span style="color: #0000ff;">var</span> column = <span style="color: #cc66cc;">0</span>; column &lt; info.rows.<span style="color: #0080ff;">length</span>; column++<span class="br0">&#41;</span> <span class="br0">&#123;</span></span>
<span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; col.<span style="color: #0080ff;">push</span><span class="br0">&#40;</span>info.rows.<span style="color: #0080ff;">item</span><span class="br0">&#40;</span>column<span class="br0">&#41;</span>.<span style="color: #0080ff;">name</span><span class="br0">&#41;</span></span>
<span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span></span>
<span>&nbsp;</span>
<span>&nbsp;</span>
<span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">for</span><span class="br0">&#40;</span><span style="color: #0000ff;">var</span> i = <span style="color: #cc66cc;">0</span>; i &lt; rs.rows.<span style="color: #0080ff;">length</span>; i++<span class="br0">&#41;</span><span class="br0">&#123;</span></span>
<span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">var</span> dic = <span class="br0">&#123;</span><span class="br0">&#125;</span></span>
<span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">for</span><span class="br0">&#40;</span><span style="color: #0000ff;">var</span> key <span style="color: #0000ff;">in</span> col<span class="br0">&#41;</span> <span class="br0">&#123;</span></span>
<span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">var</span> keyDic = col<span class="br0">&#91;</span>key<span class="br0">&#93;</span></span>
<span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">var</span> valueDic = rs.rows.<span style="color: #0080ff;">item</span><span class="br0">&#40;</span>i<span class="br0">&#41;</span><span class="br0">&#91;</span>keyDic<span class="br0">&#93;</span></span>
<span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; dic<span class="br0">&#91;</span>keyDic<span class="br0">&#93;</span> = valueDic</span>
<span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span></span>
<span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; r.<span style="color: #0080ff;">push</span><span class="br0">&#40;</span>dic<span class="br0">&#41;</span></span>
<span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span></span>
<span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; result = r</span>
<span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span></span>
<span>&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#41;</span></span>
<span>&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">return</span> result</span>
<span>&nbsp; &nbsp; <span class="br0">&#125;</span>
<span style="color: black;">&#125;</span></pre></td></tr></table></pre>
</div></blockquote>

]]></content:encoded>
			<dc:creator>Jiyuu</dc:creator>
			<guid isPermaLink="true">https://www.developpez.net/forums/blogs/135545-jiyuu/b146/connexion-gestion-d-base-donnees-qml-act-i/</guid>
		</item>
		<item>
			<title><![CDATA[Création d'une courbe en QML]]></title>
			<link>https://www.developpez.net/forums/blogs/135545-jiyuu/b143/creation-d-courbe-qml/</link>
			<pubDate>Thu, 15 Jan 2015 23:54:33 GMT</pubDate>
			<description>:salut: à tous, 
 
Voici un...</description>
			<content:encoded><![CDATA[<blockquote class="blogcontent restore">:salut: à tous,<br />
<br />
Voici un petit bout de code qui montre comment on peut créer une courbe en QML avec un système d'axes &quot;normal&quot;. J'entends par là avec l'origine en bas à gauche et non pas en haut à gauche comme le système de coordonnées de base le prévoit.<br />
<br />
Les deux plus &quot;grosses&quot; difficultés résident dans :<br />
<ul><li style="">le déplacement de l'origine à l'endroit souhaité ;</li><li style="">garder à l'esprit que l'on a potentiellement déplacer l'origine dans le canvas. </li></ul><br />
<br />
Dans le premier cas on va utiliser la propriété transform qui nous permettra de faire faire tourner notre canvas sur un ou plusieurs axes.<br />
Dans le deuxième cas, il faut juste faire attention ;-).<br />
<br />
Allez, passons à aux choses concraites... voici le code :<br />
<div class="bbcode_container">
	<table width="100%" border="0" cellspacing="0" cellpadding="0"><tr>
	<td style="border: 0; padding: 0; text-align: left">Code qml :</td>
	<td style="border: 0; padding: 0; text-align: right"><a href="#" onclick="return ano_selectionnerCode(this);">Sélectionner tout</a> -
	<a href="#" onclick="return ano_etendreCode(this);">Visualiser dans une fenêtre à part</a></td></tr></table>
	<pre class="bbcode_code" style="height:204px;"><table cellspacing="0" cellpadding="0"><tr><td valign="top" width="33"><div style="border: 1px dashed gray; padding-left: 5px; padding-right: 5px; margin-right: 5px; text-align: right; font-family: monospace">1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br />22<br />23<br />24<br />25<br />26<br />27<br />28<br />29<br />30<br />31<br />32<br />33<br />34<br />35<br />36<br />37<br />38<br />39<br />40<br />41<br />42<br />43<br />44<br />45<br />46<br />47<br />48<br />49<br />50<br />51<br />52<br />53<br /></div></td><td valign="top"><pre style="margin: 0"><span style="color: #0000ff;">import</span> QtQuick <span style="color: #cc66cc;">2.4</span>
&nbsp;
<span style="color: #0080ff;">Canvas</span> <span style="color: black;">&#123;</span>
    <span style="color: #970009;">width</span>: <span style="color: #cc66cc;">500</span>; <span style="color: #970009;">height</span>: <span style="color: #cc66cc;">500</span>
    <span style="color: #970009;">contextType</span>: <span style="color: #FF0000;">&quot;2d&quot;</span>
    <span style="color: #970009;">transform</span>: <span style="color: #0080ff;">Rotation</span> <span style="color: black;">&#123;</span> <span style="color: #970009;">origin.x</span>: <span style="color: #cc66cc;">0</span>; <span style="color: #970009;">origin.y</span>: height/<span style="color: #cc66cc;">2</span>; <span style="color: #970009;">angle</span>: <span style="color: #cc66cc;">180</span>; axis <span style="color: black;">&#123;</span> <span style="color: #970009;">x</span>: <span style="color: #cc66cc;">1</span>; <span style="color: #970009;">y</span>: <span style="color: #cc66cc;">0</span>; <span style="color: #970009;">z</span>: <span style="color: #cc66cc;">0</span> <span style="color: black;">&#125;</span><span style="color: black;">&#125;</span>
&nbsp;
    <span style="color: #0080ff;">Path</span> <span style="color: black;">&#123;</span>
        <span style="color: #970009;">id</span>: myCurve1
        <span style="color: #970009;">startX</span>: <span style="color: #cc66cc;">20</span>; <span style="color: #970009;">startY</span>: <span style="color: #cc66cc;">120</span>
        <span style="color: #0080ff;">PathCurve</span> <span style="color: black;">&#123;</span> <span style="color: #970009;">x</span>: <span style="color: #cc66cc;">40</span>; <span style="color: #970009;">y</span>: <span style="color: #cc66cc;">116</span> <span style="color: black;">&#125;</span>
        <span style="color: #0080ff;">PathCurve</span> <span style="color: black;">&#123;</span> <span style="color: #970009;">x</span>: <span style="color: #cc66cc;">60</span>; <span style="color: #970009;">y</span>: <span style="color: #cc66cc;">112</span> <span style="color: black;">&#125;</span>
        <span style="color: #0080ff;">PathCurve</span> <span style="color: black;">&#123;</span> <span style="color: #970009;">x</span>: <span style="color: #cc66cc;">80</span>; <span style="color: #970009;">y</span>: <span style="color: #cc66cc;">104</span> <span style="color: black;">&#125;</span>
        <span style="color: #0080ff;">PathCurve</span> <span style="color: black;">&#123;</span> <span style="color: #970009;">x</span>: <span style="color: #cc66cc;">100</span>; <span style="color: #970009;">y</span>: <span style="color: #cc66cc;">96</span> <span style="color: black;">&#125;</span>
        <span style="color: #0080ff;">PathCurve</span> <span style="color: black;">&#123;</span> <span style="color: #970009;">x</span>: <span style="color: #cc66cc;">120</span>; <span style="color: #970009;">y</span>: <span style="color: #cc66cc;">86</span> <span style="color: black;">&#125;</span>
        <span style="color: #0080ff;">PathCurve</span> <span style="color: black;">&#123;</span> <span style="color: #970009;">x</span>: <span style="color: #cc66cc;">140</span>; <span style="color: #970009;">y</span>: <span style="color: #cc66cc;">76</span> <span style="color: black;">&#125;</span>
        <span style="color: #0080ff;">PathCurve</span> <span style="color: black;">&#123;</span> <span style="color: #970009;">x</span>: <span style="color: #cc66cc;">160</span>; <span style="color: #970009;">y</span>: <span style="color: #cc66cc;">60</span> <span style="color: black;">&#125;</span>
        <span style="color: #0080ff;">PathCurve</span> <span style="color: black;">&#123;</span> <span style="color: #970009;">x</span>: <span style="color: #cc66cc;">180</span>; <span style="color: #970009;">y</span>: <span style="color: #cc66cc;">44</span> <span style="color: black;">&#125;</span>
        <span style="color: #0080ff;">PathCurve</span> <span style="color: black;">&#123;</span> <span style="color: #970009;">x</span>: <span style="color: #cc66cc;">200</span>; <span style="color: #970009;">y</span>: <span style="color: #cc66cc;">20</span> <span style="color: black;">&#125;</span>
    <span style="color: black;">&#125;</span>
&nbsp;
    <span style="color: #0080ff;">Path</span> <span style="color: black;">&#123;</span>
        <span style="color: #970009;">id</span>: myCurve2
        <span style="color: #970009;">startX</span>: <span style="color: #cc66cc;">20</span>; <span style="color: #970009;">startY</span>: <span style="color: #cc66cc;">120</span>
        <span style="color: #0080ff;">PathCurve</span> <span style="color: black;">&#123;</span> <span style="color: #970009;">x</span>: <span style="color: #cc66cc;">75</span>; <span style="color: #970009;">y</span>: <span style="color: #cc66cc;">75</span> <span style="color: black;">&#125;</span>
        <span style="color: #0080ff;">PathCurve</span> <span style="color: black;">&#123;</span> <span style="color: #970009;">x</span>: <span style="color: #cc66cc;">200</span>; <span style="color: #970009;">y</span>: <span style="color: #cc66cc;">150</span> <span style="color: black;">&#125;</span>
        <span style="color: #0080ff;">PathCurve</span> <span style="color: black;">&#123;</span> <span style="color: #970009;">x</span>: <span style="color: #cc66cc;">325</span>; <span style="color: #970009;">y</span>: <span style="color: #cc66cc;">25</span> <span style="color: black;">&#125;</span>
        <span style="color: #0080ff;">PathCurve</span> <span style="color: black;">&#123;</span> <span style="color: #970009;">x</span>: <span style="color: #cc66cc;">400</span>; <span style="color: #970009;">y</span>: <span style="color: #cc66cc;">100</span> <span style="color: black;">&#125;</span>
    <span style="color: black;">&#125;</span>
&nbsp;
    <span style="color: #0080ff;">Path</span> <span style="color: black;">&#123;</span>
        <span style="color: #970009;">id</span>: myAxis
        <span style="color: #970009;">startX</span>: <span style="color: #cc66cc;">20</span>; <span style="color: #970009;">startY</span>: <span style="color: #cc66cc;">20</span>
        <span style="color: #0080ff;">PathLine</span> <span style="color: black;">&#123;</span> <span style="color: #970009;">x</span>: <span style="color: #cc66cc;">20</span> ; <span style="color: #970009;">y</span>: <span style="color: #cc66cc;">300</span> <span style="color: black;">&#125;</span>
        <span style="color: #0080ff;">PathLine</span> <span style="color: black;">&#123;</span> <span style="color: #970009;">x</span>: <span style="color: #cc66cc;">20</span> ; <span style="color: #970009;">y</span>: <span style="color: #cc66cc;">20</span> <span style="color: black;">&#125;</span>
        <span style="color: #0080ff;">PathLine</span> <span style="color: black;">&#123;</span> <span style="color: #970009;">x</span>: <span style="color: #cc66cc;">450</span> ; <span style="color: #970009;">y</span>: <span style="color: #cc66cc;">20</span> <span style="color: black;">&#125;</span>
        <span style="color: #0080ff;">PathLine</span> <span style="color: black;">&#123;</span> <span style="color: #970009;">x</span>: <span style="color: #cc66cc;">20</span> ; <span style="color: #970009;">y</span>: <span style="color: #cc66cc;">20</span> <span style="color: black;">&#125;</span>
    <span style="color: black;">&#125;</span>
&nbsp;
    <span style="color: #970009;">onPaint</span>:&nbsp;<span class="br0">&#123;</span></span>
<span>&nbsp; &nbsp; &nbsp; &nbsp; context.strokeStyle = Qt.<span style="color: #0080ff;">rgba</span><span class="br0">&#40;</span><span style="color: #cc66cc;">0</span>,<span style="color: #cc66cc;">0</span>,<span style="color: #cc66cc;">1</span><span class="br0">&#41;</span>;</span>
<span>&nbsp; &nbsp; &nbsp; &nbsp; context.path = myAxis;</span>
<span>&nbsp; &nbsp; &nbsp; &nbsp; context.<span style="color: #0080ff;">stroke</span><span class="br0">&#40;</span><span class="br0">&#41;</span>;</span>
<span>&nbsp;</span>
<span>&nbsp; &nbsp; &nbsp; &nbsp; context.strokeStyle = Qt.<span style="color: #0080ff;">rgba</span><span class="br0">&#40;</span><span style="color: #cc66cc;">1</span>,<span style="color: #cc66cc;">0</span>,<span style="color: #cc66cc;">0</span><span class="br0">&#41;</span>;</span>
<span>&nbsp; &nbsp; &nbsp; &nbsp; context.path = myCurve1;</span>
<span>&nbsp; &nbsp; &nbsp; &nbsp; context.<span style="color: #0080ff;">stroke</span><span class="br0">&#40;</span><span class="br0">&#41;</span>;</span>
<span>&nbsp;</span>
<span>&nbsp; &nbsp; &nbsp; &nbsp; context.strokeStyle = Qt.<span style="color: #0080ff;">rgba</span><span class="br0">&#40;</span><span style="color: #cc66cc;">0</span>,<span style="color: #cc66cc;">1</span>,<span style="color: #cc66cc;">0</span><span class="br0">&#41;</span>;</span>
<span>&nbsp; &nbsp; &nbsp; &nbsp; context.path = myCurve2;</span>
<span>&nbsp; &nbsp; &nbsp; &nbsp; context.<span style="color: #0080ff;">stroke</span><span class="br0">&#40;</span><span class="br0">&#41;</span>;</span>
<span>&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span>
<span style="color: black;">&#125;</span></pre></td></tr></table></pre>
</div><br />
Et voila ce que cela donne :<br />
<img src="https://www.developpez.net/forums/attachments/p166302d1421365886/autres-langages/autres-langages/corba/probleme-memoire-virtuelle/exemple.png/" border="0" alt="Nom : exemple.png
Affichages : 765
Taille : 15,3 Ko"  style="float: CONFIG" /><br />
<br />
<br />
Il ne vous reste plus qu'à vous amusez :mouarf:</blockquote>

]]></content:encoded>
			<dc:creator>Jiyuu</dc:creator>
			<guid isPermaLink="true">https://www.developpez.net/forums/blogs/135545-jiyuu/b143/creation-d-courbe-qml/</guid>
		</item>
		<item>
			<title>Interaction en PyQt et un document QML</title>
			<link>https://www.developpez.net/forums/blogs/135545-jiyuu/b134/interaction-pyqt-document-qml/</link>
			<pubDate>Fri, 02 Jan 2015 21:49:33 GMT</pubDate>
			<description><![CDATA[Il y a quelques mois j'ai...]]></description>
			<content:encoded><![CDATA[<blockquote class="blogcontent restore">Il y a quelques mois j'ai rédigé un article présentant Qt Quick dans le but ensuite d'en présenter l'utilisation avec PyQt.<br />
Par manque de temps je n'ai pas pu (pour l'instant) travailler sur les articles suivants.<br />
<br />
Ayant du retravailler sur un petit projet, j'en profite pour donner un code exemple qui montre, dans les grandes lignes comment interagir entre un document QML et un script Python.<br />
<br />
Si vous avez déjà utilisé Python et QML, les morceaux de codes proposés doivent être assez explicites. Dans le cas contraire je vous invite à consulter les cours que vous trouverez sur DVP et notamment mon <a href="http://ceg.developpez.com/tutoriels/pyqt/qt-quick-python/01-interfaces-simples/" target="_blank">introduction à Qt Quick</a>   :mouarf:<br />
<br />
Code Python :<br />
<div class="bbcode_container">
	<table width="100%" border="0" cellspacing="0" cellpadding="0"><tr>
	<td style="border: 0; padding: 0; text-align: left">Code python :</td>
	<td style="border: 0; padding: 0; text-align: right"><a href="#" onclick="return ano_selectionnerCode(this);">Sélectionner tout</a> -
	<a href="#" onclick="return ano_etendreCode(this);">Visualiser dans une fenêtre à part</a></td></tr></table>
	<pre class="bbcode_code" style="height:204px;"><table cellspacing="0" cellpadding="0"><tr><td valign="top" width="33"><div style="border: 1px dashed gray; padding-left: 5px; padding-right: 5px; margin-right: 5px; text-align: right; font-family: monospace">1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br />22<br />23<br />24<br />25<br />26<br />27<br />28<br />29<br />30<br />31<br />32<br />33<br />34<br />35<br />36<br />37<br />38<br />39<br />40<br />41<br />42<br />43<br />44<br />45<br />46<br />47<br />48<br />49<br />50<br />51<br />52<br />53<br />54<br />55<br />56<br />57<br />58<br />59<br /></div></td><td valign="top"><pre style="margin: 0"><span style="color: #808080;">#!/usr/bin/env python</span>
<span style="color: #808080;"># -*- coding: utf-8 -*-</span>
&nbsp;
<span style="color: #0000ff;">import</span> sys
<span style="color: #0000ff;">from</span> PyQt5.QtCore <span style="color: #0000ff;">import</span> QObject, QUrl, pyqtSlot, QVariant
<span style="color: #0000ff;">from</span> PyQt5.QtWidgets <span style="color: #0000ff;">import</span> QApplication
<span style="color: #0000ff;">from</span> PyQt5.QtQuick <span style="color: #0000ff;">import</span> QQuickView
<span style="color: #0000ff;">from</span> PyQt5.QtQml <span style="color: #0000ff;">import</span> QQmlApplicationEngine
&nbsp;
&nbsp;
<span style="color: #0000ff;">class</span> MainApp<span class="br0">&#40;</span>QObject<span class="br0">&#41;</span>:
    <span style="color: #0000ff;">def</span> <span style="color: #0080ff;">__init__</span><span class="br0">&#40;</span>self, parent=<span style="color: #339933;">None</span><span class="br0">&#41;</span>:
        super<span class="br0">&#40;</span>MainApp, self<span class="br0">&#41;</span>.<span style="color: #0080ff;">__init__</span><span class="br0">&#40;</span>parent<span class="br0">&#41;</span>
&nbsp;
        self.win = parent
        self.win.findChild<span class="br0">&#40;</span>QObject,<span style="color: #FF0000;">&quot;myButton&quot;</span><span class="br0">&#41;</span>.clicked.connect<span class="br0">&#40;</span>self.test3<span class="br0">&#41;</span>
&nbsp;
&nbsp;
<span style="color: #339933;">&nbsp; &nbsp; @pyqtSlot<span class="br0">&#40;</span>QVariant<span class="br0">&#41;</span></span>
    <span style="color: #0000ff;">def</span> test<span class="br0">&#40;</span>self, ctx<span class="br0">&#41;</span>:
        txt = <span style="color: #FF0000;">&quot;Test by contextProperty&quot;</span>
        ctx.setContextProperty<span class="br0">&#40;</span><span style="color: #FF0000;">&quot;retour&quot;</span>, txt<span class="br0">&#41;</span>
&nbsp;
        <span style="color: #0000ff;">return</span> <span style="color: #cc66cc;">0</span>
&nbsp;
&nbsp;
<span style="color: #339933;">&nbsp; &nbsp; @pyqtSlot<span class="br0">&#40;</span>result=QVariant<span class="br0">&#41;</span></span>
    <span style="color: #0000ff;">def</span> test2<span class="br0">&#40;</span>self<span class="br0">&#41;</span>:
&nbsp;
        <span style="color: #0000ff;">return</span> <span style="color: #FF0000;">'Test by direct call'</span>
&nbsp;
&nbsp;
    <span style="color: #0000ff;">def</span> test3<span class="br0">&#40;</span>self<span class="br0">&#41;</span>:
        txt = self.win.findChild<span class="br0">&#40;</span>QObject, <span style="color: #FF0000;">&quot;myTextField&quot;</span><span class="br0">&#41;</span>
        txt.setProperty<span class="br0">&#40;</span><span style="color: #FF0000;">&quot;text&quot;</span>, <span style="color: #FF0000;">&quot;Test by name&quot;</span><span class="br0">&#41;</span>
&nbsp;
        <span style="color: #0000ff;">return</span> <span style="color: #cc66cc;">0</span>
&nbsp;
&nbsp;
&nbsp;
<span style="color: #0000ff;">if</span> <span style="color: #0080ff;">__name__</span> == <span style="color: #FF0000;">&quot;__main__&quot;</span>:
    app = QApplication<span class="br0">&#40;</span>sys.argv<span class="br0">&#41;</span>
&nbsp;
    engine = QQmlApplicationEngine<span class="br0">&#40;</span><span class="br0">&#41;</span>
    ctx = engine.rootContext<span class="br0">&#40;</span><span class="br0">&#41;</span>
&nbsp;
    txt = <span style="color: #FF0000;">&quot;Test by ContextProperty&quot;</span>
    ctx.setContextProperty<span class="br0">&#40;</span><span style="color: #FF0000;">&quot;titreBtn&quot;</span>, txt<span class="br0">&#41;</span>
    ctx.setContextProperty<span class="br0">&#40;</span><span style="color: #FF0000;">&quot;ctx&quot;</span>, ctx<span class="br0">&#41;</span>
&nbsp;
    engine.load<span class="br0">&#40;</span><span style="color: #FF0000;">'gui.qml'</span><span class="br0">&#41;</span>
    win = engine.rootObjects<span class="br0">&#40;</span><span class="br0">&#41;</span><span class="br0">&#91;</span><span style="color: #cc66cc;">0</span><span class="br0">&#93;</span>
&nbsp;
    _MainApp = MainApp<span class="br0">&#40;</span>win<span class="br0">&#41;</span>
    ctx.setContextProperty<span class="br0">&#40;</span><span style="color: #FF0000;">&quot;py_MainApp&quot;</span>, _MainApp<span class="br0">&#41;</span>
&nbsp;
    win.showMaximized<span class="br0">&#40;</span><span class="br0">&#41;</span>
&nbsp;
    sys.exit<span class="br0">&#40;</span>app.exec_<span class="br0">&#40;</span><span class="br0">&#41;</span><span class="br0">&#41;</span></pre></td></tr></table></pre>
</div><br />
Code QML<br />
<div class="bbcode_container">
	<table width="100%" border="0" cellspacing="0" cellpadding="0"><tr>
	<td style="border: 0; padding: 0; text-align: left">Code qml :</td>
	<td style="border: 0; padding: 0; text-align: right"><a href="#" onclick="return ano_selectionnerCode(this);">Sélectionner tout</a> -
	<a href="#" onclick="return ano_etendreCode(this);">Visualiser dans une fenêtre à part</a></td></tr></table>
	<pre class="bbcode_code" style="height:204px;"><table cellspacing="0" cellpadding="0"><tr><td valign="top" width="33"><div style="border: 1px dashed gray; padding-left: 5px; padding-right: 5px; margin-right: 5px; text-align: right; font-family: monospace">1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br />22<br />23<br />24<br />25<br />26<br />27<br />28<br />29<br />30<br />31<br />32<br />33<br />34<br />35<br />36<br />37<br />38<br />39<br />40<br />41<br />42<br />43<br />44<br />45<br />46<br />47<br />48<br />49<br />50<br />51<br />52<br />53<br />54<br />55<br />56<br />57<br />58<br />59<br />60<br />61<br />62<br />63<br />64<br />65<br />66<br />67<br />68<br />69<br />70<br />71<br />72<br />73<br />74<br />75<br />76<br />77<br />78<br />79<br /></div></td><td valign="top"><pre style="margin: 0"><span style="color: #0000ff;">import</span> QtQuick <span style="color: #cc66cc;">2.4</span>
<span style="color: #0000ff;">import</span> QtQuick.Controls <span style="color: #cc66cc;">1.3</span>
<span style="color: #0000ff;">import</span> QtQuick.<span style="color: #0080ff;">Window</span> <span style="color: #cc66cc;">2.2</span>
<span style="color: #0000ff;">import</span> QtQuick.Dialogs <span style="color: #cc66cc;">1.2</span>
<span style="color: #0000ff;">import</span> QtQuick.Layouts <span style="color: #cc66cc;">1.1</span>
&nbsp;
&nbsp;
<span style="color: #0080ff;">ApplicationWindow</span> <span style="color: black;">&#123;</span>
    <span style="color: #970009;">title</span>: qsTr<span style="color: black;">&#40;</span><span style="color: #FF0000;">&quot;Test&quot;</span><span style="color: black;">&#41;</span>
    <span style="color: #970009;">width</span>: <span style="color: #cc66cc;">640</span>
    <span style="color: #970009;">height</span>: <span style="color: #cc66cc;">480</span>
&nbsp;
    <span style="color: #970009;">menuBar</span>: <span style="color: #0080ff;">MenuBar</span> <span style="color: black;">&#123;</span>
        <span style="color: #0080ff;">Menu</span> <span style="color: black;">&#123;</span>
            <span style="color: #970009;">title</span>: qsTr<span style="color: black;">&#40;</span><span style="color: #FF0000;">&quot;&amp;File&quot;</span><span style="color: black;">&#41;</span>
            <span style="color: #0080ff;">MenuItem</span> <span style="color: black;">&#123;</span>
                <span style="color: #970009;">text</span>: qsTr<span style="color: black;">&#40;</span><span style="color: #FF0000;">&quot;&amp;Open&quot;</span><span style="color: black;">&#41;</span>
                <span style="color: #970009;">onTriggered</span>: messageDialog.show<span style="color: black;">&#40;</span>qsTr<span style="color: black;">&#40;</span><span style="color: #FF0000;">&quot;Open action triggered&quot;</span><span style="color: black;">&#41;</span><span style="color: black;">&#41;</span>;
            <span style="color: black;">&#125;</span>
            <span style="color: #0080ff;">MenuItem</span> <span style="color: black;">&#123;</span>
                <span style="color: #970009;">text</span>: qsTr<span style="color: black;">&#40;</span><span style="color: #FF0000;">&quot;E&amp;xit&quot;</span><span style="color: black;">&#41;</span>
                <span style="color: #970009;">onTriggered</span>: <span style="color: #0080ff;">Qt</span>.quit<span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>;
            <span style="color: black;">&#125;</span>
        <span style="color: black;">&#125;</span>
    <span style="color: black;">&#125;</span>
&nbsp;
    <span style="color: #0080ff;">GridLayout</span> <span style="color: black;">&#123;</span>
        <span style="color: #970009;">id</span> : grid
        <span style="color: #970009;">columns</span> : <span style="color: #cc66cc;">6</span>
        <span style="color: #970009;">columnSpacing</span>: <span style="color: #cc66cc;">5</span>
        <span style="color: #970009;">anchors.fill</span>: parent
        <span style="color: #970009;">anchors.margins</span>: <span style="color: #cc66cc;">10</span>
&nbsp;
        <span style="color: #0080ff;">RowLayout</span> <span style="color: black;">&#123;</span>
            <span style="color: #970009;">id</span> : nav
            L<span style="color: #970009;">ayout.fillWidth</span>: <span style="color: #339933;">true</span>
            L<span style="color: #970009;">ayout.columnSpan</span>: grid.columns
&nbsp;
            <span style="color: #0080ff;">TextField</span><span style="color: black;">&#123;</span>
                <span style="color: #970009;">id</span> : txt
                <span style="color: #970009;">objectName</span>: <span style="color: #FF0000;">&quot;myTextField&quot;</span>
                L<span style="color: #970009;">ayout.fillWidth</span>: <span style="color: #339933;">true</span>
            <span style="color: black;">&#125;</span>
            <span style="color: #0080ff;">Button</span><span style="color: black;">&#123;</span>
                <span style="color: #970009;">objectName</span>: <span style="color: #FF0000;">&quot;myButton&quot;</span>
                <span style="color: #970009;">text</span> : <span style="color: #FF0000;">&quot;Test byName&quot;</span>
            <span style="color: black;">&#125;</span>
            <span style="color: #0080ff;">Button</span><span style="color: black;">&#123;</span>
                <span style="color: #970009;">text</span> : titreBtn
                <span style="color: #970009;">onClicked</span>:&nbsp;<span class="br0">&#123;</span></span>
<span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; py_MainApp.<span style="color: #0080ff;">test</span><span class="br0">&#40;</span>ctx<span class="br0">&#41;</span></span>
<span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; txt.<span style="color: #0080ff;">text</span> = retour</span>
<span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span>
            <span style="color: black;">&#125;</span>
            <span style="color: #0080ff;">Button</span><span style="color: black;">&#123;</span>
                <span style="color: #970009;">text</span> : <span style="color: #FF0000;">&quot;Test de retour&quot;</span>
                <span style="color: #970009;">onClicked</span>: txt.text = py_MainApp.test2<span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
            <span style="color: black;">&#125;</span>
        <span style="color: black;">&#125;</span>
&nbsp;
        <span style="color: #0080ff;">TextArea</span><span style="color: black;">&#123;</span>
            <span style="color: #970009;">id</span>: result
            L<span style="color: #970009;">ayout.fillWidth</span>: <span style="color: #339933;">true</span>
            L<span style="color: #970009;">ayout.fillHeight</span>: <span style="color: #339933;">true</span>
            L<span style="color: #970009;">ayout.columnSpan</span>: grid.columns
        <span style="color: black;">&#125;</span>
   <span style="color: black;">&#125;</span>
&nbsp;
&nbsp;
   <span style="color: #0080ff;">MessageDialog</span> <span style="color: black;">&#123;</span>
        <span style="color: #970009;">id</span>: messageDialog
        <span style="color: #970009;">title</span>: qsTr<span style="color: black;">&#40;</span><span style="color: #FF0000;">&quot;May I have your attention, please?&quot;</span><span style="color: black;">&#41;</span>
&nbsp;
        <span style="color: #0000ff;">function</span> <span style="color: #0080ff;">show</span><span class="br0">&#40;</span>caption<span class="br0">&#41;</span> <span class="br0">&#123;</span></span>
<span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; messageDialog.<span style="color: #0080ff;">text</span> = caption;</span>
<span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; messageDialog.<span style="color: #0080ff;">open</span><span class="br0">&#40;</span><span class="br0">&#41;</span>;</span>
<span>&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span>
    <span style="color: black;">&#125;</span>
<span style="color: black;">&#125;</span></pre></td></tr></table></pre>
</div></blockquote>

]]></content:encoded>
			<dc:creator>Jiyuu</dc:creator>
			<guid isPermaLink="true">https://www.developpez.net/forums/blogs/135545-jiyuu/b134/interaction-pyqt-document-qml/</guid>
		</item>
	</channel>
</rss>
