creating a qt widget based application from qt creator manual

41
Creating a Qt Widget Based Application From Qt Creator Manual

Upload: kristin-atkins

Post on 14-Dec-2015

234 views

Category:

Documents


3 download

TRANSCRIPT

Page 1: Creating a Qt Widget Based Application From Qt Creator Manual

Creating a Qt Widget Based Application

From Qt Creator Manual

Page 2: Creating a Qt Widget Based Application From Qt Creator Manual

Overview• Have had some experience with Qt

– … messing with Creator … compiling …

• Next real step is to design and implementations of your own programs

• Follow the old maxim about programming:– If at all possible, don’t!

• Qt and such “frameworks” programs/systems are all about that– “Allow the user of our system to focus on the design …” vs. code

• Nonetheless, the complexity of such programs are not to be underestimated … especially, if it’s your first or second exposure to such large interacting systems– And ui programming is a paradigm example

• Will go explicitly through the steps of creating all files and a project

• Qt tutorials are pretty good

Page 3: Creating a Qt Widget Based Application From Qt Creator Manual

Qt Creator Manual• Definitive source• Only (formally published) place to get most recent information

– Forums …. Forums Forums

• When open Qt Creator -> Help -> Contents

Page 4: Creating a Qt Widget Based Application From Qt Creator Manual

Qt Creator Manual• General and

specific information

• Tutorials

Page 5: Creating a Qt Widget Based Application From Qt Creator Manual

Tutorials• Creating a Qt

Widget Based Application

Page 6: Creating a Qt Widget Based Application From Qt Creator Manual

Creating a Qt Widget Based Application• Steps begin

Page 7: Creating a Qt Widget Based Application From Qt Creator Manual

Creating a Qt Widget Based Application• Steps begin

• Summarized at right

• “One at a time

Page 8: Creating a Qt Widget Based Application From Qt Creator Manual

Creating the Project

Page 9: Creating a Qt Widget Based Application From Qt Creator Manual

Creating the Project - 1

• Steps begin

• Choose which application type

• Qt Widgets application

Page 10: Creating a Qt Widget Based Application From Qt Creator Manual

Creating the Project – 1a, 2

• Then, name and location of project

Page 11: Creating a Qt Widget Based Application From Qt Creator Manual

Creating the Project – 3

• Then, will see things about “kits” (next slide)

Page 12: Creating a Qt Widget Based Application From Qt Creator Manual

Creating the Project – 4-6• Qt selects

correct kits for you (based on your selection of project type)– “Kits” =

classes, libraries, etc.

• Will have to specify “Base class”– Recall from

discussion of class hierarchy

• Note: This where names of the several files are determined

Page 13: Creating a Qt Widget Based Application From Qt Creator Manual

Creating the Project – 7-8

• So far, no real “project management” to do

• Next, editor opens

Page 14: Creating a Qt Widget Based Application From Qt Creator Manual

Creating the Project – What is Created

• Files at right are created when “class name” specified to be “textfinder”

Page 15: Creating a Qt Widget Based Application From Qt Creator Manual

Creating the Project – What is Created

• Files created when “class name” specified to be “textfinder”

• These are the files you will work with and modify!

• Call them:– “boiler plate”– “shells”– …

Page 16: Creating a Qt Widget Based Application From Qt Creator Manual

Filling in the Missing Pieces

Page 17: Creating a Qt Widget Based Application From Qt Creator Manual

Filling in the Missing Pieces

Page 18: Creating a Qt Widget Based Application From Qt Creator Manual

Specify User Interface Elements - 0

• Qt calls the widgets the “User interface”– Which it is– BUT, there is

no particular design included, except what inherent in Qt

• Will both create and design with Qt Creator

• Now have: <fname>.ui

Page 19: Creating a Qt Widget Based Application From Qt Creator Manual

Specify User Interface Elements – 1-2

• Start Qt Designer and add widgets …

• Learn about Designer as you go …

Page 20: Creating a Qt Widget Based Application From Qt Creator Manual

Specify User Interface Elements – 3-6

• Starting with above, get to at right

• Learn about Designer as you go …

• Tutorial mentions some things

Page 21: Creating a Qt Widget Based Application From Qt Creator Manual

Filling in the Missing Pieces

Page 22: Creating a Qt Widget Based Application From Qt Creator Manual

Header and Source Files – 9-10

• Connect widget signals and slots (functions)

Page 23: Creating a Qt Widget Based Application From Qt Creator Manual

Qt Creator: Connecting Slots & Signals• Can also use Qt Creator to connect signals and slots

– From last assignment

Page 24: Creating a Qt Widget Based Application From Qt Creator Manual

Qt Creator: Connecting Slots & Signals• E.g., as tutorial says … below, after right click on top button

– and selecting “Got to slot” from context menu (context menu not shown

Page 25: Creating a Qt Widget Based Application From Qt Creator Manual

Qt Creator: Connecting Slots & Signals• And there are other ways to connect signals and slots

– Again, below, Qt Creator – from last assignment

Page 26: Creating a Qt Widget Based Application From Qt Creator Manual

Qt Creator: Connecting Slots & Signals• Qt Creator – “Signals and Slots Editor”

– Select tab

Page 27: Creating a Qt Widget Based Application From Qt Creator Manual

Qt Creator: Connecting Slots & Signals• “Signals and Slots Editor” – click green “+” to add signal/slot pair

– How know that? – read or try

Page 28: Creating a Qt Widget Based Application From Qt Creator Manual

Completing the Source File

Page 29: Creating a Qt Widget Based Application From Qt Creator Manual

Completing the Source File – Overview

• Add code elements to “shells”

Page 30: Creating a Qt Widget Based Application From Qt Creator Manual

Completing the Source File – 1-2

Page 31: Creating a Qt Widget Based Application From Qt Creator Manual

Completing the Source File – 3-4

Page 32: Creating a Qt Widget Based Application From Qt Creator Manual

Completing the Source File – 5

Page 33: Creating a Qt Widget Based Application From Qt Creator Manual

Creating a Resource File

Page 34: Creating a Qt Widget Based Application From Qt Creator Manual

Creating a Resource File - 1• Some

projects will require yet one more file

Page 35: Creating a Qt Widget Based Application From Qt Creator Manual

Creating a Resource File – 1a-2• File

locations

Page 36: Creating a Qt Widget Based Application From Qt Creator Manual

Creating a Resource File – 2-3• More file

locations and integrate with project

Page 37: Creating a Qt Widget Based Application From Qt Creator Manual

Creating a Resource File – 4-7• Now, in ide

Page 38: Creating a Qt Widget Based Application From Qt Creator Manual

Compiling and Running – old hat

Page 39: Creating a Qt Widget Based Application From Qt Creator Manual

… and run it, ……………………..• In ide …

Page 40: Creating a Qt Widget Based Application From Qt Creator Manual

… and run it, then … next tutorial!• In ide …

Page 41: Creating a Qt Widget Based Application From Qt Creator Manual

End• .