Creating a Qt Widget Based Application From Qt Creator Manual

Preview:

Citation preview

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

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

– Forums …. Forums Forums

• When open Qt Creator -> Help -> Contents

Qt Creator Manual• General and

specific information

• Tutorials

Tutorials• Creating a Qt

Widget Based Application

Creating a Qt Widget Based Application• Steps begin

Creating a Qt Widget Based Application• Steps begin

• Summarized at right

• “One at a time

Creating the Project

Creating the Project - 1

• Steps begin

• Choose which application type

• Qt Widgets application

Creating the Project – 1a, 2

• Then, name and location of project

Creating the Project – 3

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

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

Creating the Project – 7-8

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

• Next, editor opens

Creating the Project – What is Created

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

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”– …

Filling in the Missing Pieces

Filling in the Missing Pieces

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

Specify User Interface Elements – 1-2

• Start Qt Designer and add widgets …

• Learn about Designer as you go …

Specify User Interface Elements – 3-6

• Starting with above, get to at right

• Learn about Designer as you go …

• Tutorial mentions some things

Filling in the Missing Pieces

Header and Source Files – 9-10

• Connect widget signals and slots (functions)

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

– From last assignment

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

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

– Again, below, Qt Creator – from last assignment

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

– Select tab

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

– How know that? – read or try

Completing the Source File

Completing the Source File – Overview

• Add code elements to “shells”

Completing the Source File – 1-2

Completing the Source File – 3-4

Completing the Source File – 5

Creating a Resource File

Creating a Resource File - 1• Some

projects will require yet one more file

Creating a Resource File – 1a-2• File

locations

Creating a Resource File – 2-3• More file

locations and integrate with project

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

Compiling and Running – old hat

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

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

End• .

Recommended