Introduction à Qt et Qt Creator

17
Introduction à Qt et Qt Creator Installation Pt1: Application Console Pt2: Application Hello World

description

Introduction à Qt et Qt Creator. Installation Pt1: Application Console Pt2: Application Hello World. Installation de Qt. Télécharger le Qt SDK http://qt.nokia.com/downloads. Installer le Qt SDK 2009.03 Qt Creator Qt 4.5.2 MinGW 5.1.4. Configurer les Variables d’Environnement - PowerPoint PPT Presentation

Transcript of Introduction à Qt et Qt Creator

Page 1: Introduction à Qt et Qt Creator

Introduction à Qt et Qt CreatorInstallation

Pt1: Application ConsolePt2: Application Hello World

Page 2: Introduction à Qt et Qt Creator

Installation de Qt

• Télécharger le Qt SDK– http://qt.nokia.com/downloads

Page 3: Introduction à Qt et Qt Creator

• Installer le Qt SDK 2009.03– Qt Creator– Qt 4.5.2– MinGW 5.1.4

Page 4: Introduction à Qt et Qt Creator

• Configurer les Variables d’Environnement– Clique-droit sur MyComputer,– Properties>Advanced>Environment Variables

• Verifier que QTDIR est au bon chemain d’installation (C:\Qt\2009.03\qt)

• Ajouter à la variable PATH le chemin vers les exécutables (C:\Qt\2009.03\qt\bin)

– Pour utiliser le compilateur de Visual Studio• Ajouter une variable QMAKESPEC : win32-msvc2005,

sous System Variables

Page 5: Introduction à Qt et Qt Creator

• Ouvrir Visual Studio 2005 Command Prompt– aller au chemin d'installation– lancer l'outil de configuration

• configure –debug-and-release

• Ensuite, compiler avec nmake

Page 6: Introduction à Qt et Qt Creator

• Vous souhaitez utiliser Qt avec Visual Studio sous Windows?

• Téléchargez le module d'extension Visual Studio, et utilisez-le pour développer, avec toutes les licences Qt.

– Visual Studio Add-in (40 Mb)• http://qt.nokia.com/downloads

Page 7: Introduction à Qt et Qt Creator

Pt 1: Application Console• Lancer Qt Creator• Sélectionner File > New > Qt4 Console Application• Donner le nom TutorialPt1• Sélectionner Next (jusqu’au bout)

Page 8: Introduction à Qt et Qt Creator

• Ajouter la fonction au projet– Dans ce cas:

• Le fichier source tutorialfunction.cpp • Le fichier header tutorialfunction.h

• Vérifier s’ils ont été ajoutés au fichier .pro

Page 9: Introduction à Qt et Qt Creator

• Ouvrir main.cpp• Ajouter le header de la fonction• Appeler la fonction, pour qu’elle soit

exécutée lorsque l'application est exécutée

Page 10: Introduction à Qt et Qt Creator

• Sélectionner File > Save All• Sélectionner la commande run

• La fonction devrait être exécutée

Page 11: Introduction à Qt et Qt Creator

Pt2: Application Hello World• Lancer Qt Creator• Sélectionner File > New > Qt4 Gui Application• Donner le nom HelloWorld• Sélectionner Next (jusqu’au bout)

Page 12: Introduction à Qt et Qt Creator

• Ouvrir mainwindow.ui• Ajouter

• un pushButton, retrouvé sous Buttons,• un lineEdit, retrouvé sous Input Widgets• un label, retrouvé sous Display Widgets

Page 13: Introduction à Qt et Qt Creator

• Sélectionner Edit signals/slots• Choisir le pushButton

• glisser-déposer la ligne rouge pour ouvrir la fenêtreConfigure Connection

• Sélectionner clicked() et finalement, Edit…

Page 14: Introduction à Qt et Qt Creator

• Ajouter un nouveau Slot au nom de buttonClickHandler()

• Sélectionner OK

• Une fois revenu à la fenêtre Configure Connection, sélectionner clicked() et buttonClickHandler()

• Sélectionner OK

Page 15: Introduction à Qt et Qt Creator

• Ouvrir mainwindow.h• Ajouter le Slot buttonClickHandler()

Page 16: Introduction à Qt et Qt Creator

• Ouvrir mainwindow.cpp• Ajouter l’implémentation pour buttonClickHandler()

• ui->label->setText();• Utiliser le paramètre suivant : ui->lineEdit->text()

Page 17: Introduction à Qt et Qt Creator

• Sélectionner File > Save All• Sélectionner la commande run

• Vérifier le bon fonctionnement de l’exemple• taper “Hello Qt World!” dans le champ lineEdit• Sélectionner PushButton• L’étiquette lit maintenant “Hello Qt World!”