Best Practices in QT Quick
Best Practices in QT Quick
Best Practices in QT Quick
Quick/QML
Langston Ball
Senior Qt Developer
ICS, Inc.
Topics
Introduction
Integrating C++ and QML
Anchors Are Your Friend
Keyboard and Input Handling
Closing
Introduction
(Delete if not used)
Comparison of approaches
Design differences
qmlRegisterType()
qmlRegisterInterface()
qmlRegisterUncreatableType()
qmlRegisterSingletonType()
QML can utilize the signal of your c++ objects and its properties
It can also utilize slots inside those objects
public slots as well as ones marked with Q_INVOKABLE macro
These features make using c++ backends ideal for controlling the UI and
allow for a clean seperation of UI and logic.
QQmlExtensionPlugin
Using plug-ins
Kinds of models
Kinds of views
ListModels
Static
Dynamic
Delegate
Special delegate properties
C++ Models with QML Views
What about trees?
Closing
(Fill in)
Principles of layout
Property bindings
Issues with bindings
Complex property bindings
Anchor lines
Introduction to anchors
Margins
Anchor Lines
Anchor lines contain no value, only a reference to an Item and an enum value
for which line it is referring to.
Introduction to Anchors
Figure 1.3 shows two rectangles that grow as the parent window grows.
(before resize)
(after resize)
text: "Third"
onClicked: console.log("Third")
}
FocusableButton {
focusOnClick: false
4
5
6
7
Focus debug items can display the state of non-visual items as well
as visual ones.
There's no need to devote extra screen estate to the debug items,
as they can be small (conveying just two bits of information per
item) and naturally placed on top of the items they relate to.
Having all necessary focus state displayed on top of the "debugged"
items allows to track it with ease, comfortably checking one's
assumptions about the application focus state and behavior and
catching (otherwise tricky) errors early.
Items without active focus still forward key events, which may
highly complicate event handling (unless forwarding is disabled in
the absence of active focus).
Disabled items still get forwarded keyboard input, but invisible items
don't.
Built-in text editing items can be fed forwarded input, TextInput's
onAccepted() will be triggered when a forwarded Enter or Return
press is received.
Summary
1.
2.
3.
4.
5.
Back-up Slides