SlideShare une entreprise Scribd logo
1  sur  53
Télécharger pour lire hors ligne
© Integrated Computer Solutions, Inc. All Rights Reserved
Best Practices in Qt
Quick/QML Part 3
Justin Noel
Senior Consulting Engineer
ICS, Inc.
© Integrated Computer Solutions, Inc. All Rights Reserved
Agenda
• C++ / QML Integration
• Reusing Existing C++ Code
© Integrated Computer Solutions, Inc. All Rights Reserved
Using C++ and QML
© Integrated Computer Solutions, Inc. All Rights Reserved
Drive QML with C++
© Integrated Computer Solutions, Inc. All Rights Reserved
Model – View Pattern
• C++ code can know nothing about the UI
• Properties, Slots and Signals are the interface in QML
• QML Items connect or bind to C++ Objects
• Good Design is Enforced
• C++ cannot depend on UI
• Avoids “accidental” storage of data inside UI
components
• C++ is more portable to other UI frameworks
© Integrated Computer Solutions, Inc. All Rights Reserved
C++ Integration Techniques
• Expose object instances from C++ to QML
• Objects appear as global variables to QML
• Effectively singletons
• Expose C++ types to QML
• New types are available for QML programmers to use
• Remember how Rectangle and Text are actually
C++?
© Integrated Computer Solutions, Inc. All Rights Reserved
Creating Properties in C++
• Properties are the combination of
• Read function
• Write function
• Notify signal
• Signals/slots is Qt’s object communication
system
© Integrated Computer Solutions, Inc. All Rights Reserved
Creating Properties in C++
• Inherit from QObject
• Use the Q_OBJECT macro
• Use the Q_PROPERTY macro
© Integrated Computer Solutions, Inc. All Rights Reserved
C++ Property Header
class CoffeeMaker : public QObject
{
Q_OBJECT
Q_PROPERTY(int temp READ getTemp WRITE setTemp NOTIFY tempChanged)
public:
int getTemp() const;
void setTemp(int temp);
signals:
void tempChanged(); // Parameter is not required by QtQuick
private:
int m_temp;
};
© Integrated Computer Solutions, Inc. All Rights Reserved
Source is as usual
int CoffeeMaker ::getTemp() const
{
return m_temp;
}
void CoffeeMaker ::setTemp(int temp)
{
if(m_temp != temp)
{
m_temp = temp;
emit tempChanged();
}
}
© Integrated Computer Solutions, Inc. All Rights Reserved
Invokable C++ Methods
• Methods can be called from QML
• Any slot can be called
• Any Q_INVOKABLE can be called
© Integrated Computer Solutions, Inc. All Rights Reserved
Invokable C++ Return Types
• Any basic Qt or C++ type
• int, double, QString, etc
• Any returned QObject* belongs to QML
• Will be deleted by QML during GC
• NOTE: QObject* returned from a Q_PROPERTY
belongs to C++
© Integrated Computer Solutions, Inc. All Rights Reserved
Invokable C++ Functions
class CoffeeMaker : public QObject
{
Q_OBJECT
Q_PROPERTY(int temp READ getTemp WRITE setTemp NOTIFY tempChanged)
public:
int getTemp() const;
void setTemp(int temp);
Q_INVOKABLE void startBrew();
public slots:
void stopBrew();
signals:
void tempChanged(); //Using a parameter is not required by QtQuick
};
© Integrated Computer Solutions, Inc. All Rights Reserved
Exposing Instances
int main(int argc, char** argv)
{
QGuiApplication app(argc, argv);
CoffeeMaker maker;
QQuickView view;
view.rootContext()->setContextProperty(“maker”, &maker);
view.setSource(Qurl(“qrc:/main.qml”));
view.show();
return app.exec();
}
© Integrated Computer Solutions, Inc. All Rights Reserved
Basic C++ Integration QML
import QtQuick 2.2
Rectangle {
width: 1024
height: 768
Text {
anchors.centerIn: parent
text: “Coffee Temp” + maker.temp
}
MouseArea {
anchors.fill: parent
onClicked: maker.startBrew();
}
}
© Integrated Computer Solutions, Inc. All Rights Reserved
Complex Properties
• QObject* can be used as a property
• Used for encapsulation and creating trees of
properties
• Properties can have properties!
© Integrated Computer Solutions, Inc. All Rights Reserved
Complex Properties Header
class CoffeeMaker : public QObject
{
Q_OBJECT
Q_PROPERTY(QObject* options READ getOptions CONSTANT)
public:
QObject* getOptions() const { return &m_options; };
Q_INVOKABLE void startBrew();
private:
Options m_options;
};
© Integrated Computer Solutions, Inc. All Rights Reserved
Complex Properties Header
class Options: public QObject
{
Q_OBJECT
Q_PROPERTY(int temp READ getTemp WRITE setTemp NOTIFY tempChanged)
public:
int getTemp() const;
void setTemp(int temp);
signals:
void tempChanged();
};
© Integrated Computer Solutions, Inc. All Rights Reserved
Complex Properties QML
import QtQuick 2.2
Rectangle {
width: 1024
height: 768
Text {
anchors.centerIn: parent
text: “Coffee temp” + maker.options.temp
}
MouseArea {
anchors.fill: parent
onClicked: maker.startBrew();
}
}
© Integrated Computer Solutions, Inc. All Rights Reserved
Enum Properties
• C++ enums can be used as QML types
• Use Q_ENUMS macro
• Use qmlRegisterUncreatableType<>(…)
• Package Name
• Major Version
• Minor Version
• Type Name
• Error Message
© Integrated Computer Solutions, Inc. All Rights Reserved
Enum Properties Header
class CoffeeMaker: public QObject
{
Q_OBJECT
Q_PROPERTY(Strength strength READ getStrength
WRITE setStrength
NOTIFY strengthChanged)
public:
CoffeeMaker();
enum Strength { Light, Medium, Dark }; Q_ENUM(Strength)
Strength getStrength() const;
void setStrength(Strength newStrength);
signals:
void strengthChanged();
};
© Integrated Computer Solutions, Inc. All Rights Reserved
Enum Properties Source
CoffeeMaker::CoffeeMaker()
{
qmlRegisterUncreatableType<CoffeeMaker>(“MrCoffee”,
1, 0,
“CoffeeMaker”,
“Do not instance.”);
}
© Integrated Computer Solutions, Inc. All Rights Reserved
Enum Properties QML
import QtQuick 2.2
import MrCoffee 1.0 //Needed to get TypeInfo for CoffeeMaker
Rectangle {
width: 1024
height: 768
Text {
anchors.centerIn: parent
text:textFromStrength(maker.strength)//Evaluated as int
}
function textFromStrength(strength) { … }
MouseArea {
anchors.fill: parent
onClicked: maker.startBrew(CoffeeMaker.Strong); //Used by name
}
}
© Integrated Computer Solutions, Inc. All Rights Reserved
Reusing Existing Code
• QML requires that properties
• READ functions returns correct value
• Could be called anytime
• NOTIFY signal emitted when prop changes
• Immediate call to READ returns new changed
value
© Integrated Computer Solutions, Inc. All Rights Reserved
Reuse Techniques
• Direct – Add Q_PROPERTY
• Model is already QObject based
• Stores its own data
• Wrapper – Write a new QObject class
• Model is not (or cannot be) QObject based
• Model does not store data
© Integrated Computer Solutions, Inc. All Rights Reserved
Direct Reuse Technique
• Use Q_PROPERTY with existing
• READ function
• WRITE function (optional)
• NOTIFY signal
• Use Q_INVOKABLE on existing methods
• Functions you want callable from the UI
© Integrated Computer Solutions, Inc. All Rights Reserved
Existing Header
class CoffeeMaker : public QObject
{
Q_OBJECT
public:
float targetTemp() const;
void setTargetTemp(float taregetTemp);
float temp() const;
signals:
void targetTempChanged(float targetTemp);
void tempChanged(float temp);
private:
… //Members
};
© Integrated Computer Solutions, Inc. All Rights Reserved
Direct Reuse Header
class CoffeeMaker : public QObject
{
Q_OBJECT
Q_PROPERTY(float targetTemp READ targetTemp NOTIFY targetTempChanged)
Q_PROPERTY(float temp READ temp NOTIFY tempChanged
public:
float targetTemp() const;
Q_INVOKABLE void setTargetTemp(float taregetTemp);
float temp() const;
signals:
void targetTempChanged(float targetTemp);
void tempChanged(float temp);
...
};
© Integrated Computer Solutions, Inc. All Rights Reserved
Read Only Properties
• Properties can be read-only
• Slots or Q_INVOKABLE functions
• Can change state and emit signals
• Sometimes it’s cleaner to have
• Read only properties
• Q_INVOKABLE setter functions
© Integrated Computer Solutions, Inc. All Rights Reserved
Direct Reuse Issues
• Inherited NOTIFY signals compile error
• NOTIFY signal needs be in the same class as
Q_PROPERTY declaration
• Workaround:
• Specify new signal in subclass
• Use SIGNAL – SIGNAL connection in ctor
© Integrated Computer Solutions, Inc. All Rights Reserved
Wrapper Reuse Technique
• Class that provides the QObject interface
• Inheritance
• Composition – Easier to test
• Less chance of “rocking the boat”
• More typing. More code
© Integrated Computer Solutions, Inc. All Rights Reserved
Wrappers fix a lot of issues
• Class is template based
• Can’t directly inherit Qobject
• Class does not use signals
• Uses some other callback mechanism
• Class does not follow get/set/notify pattern
• Wrapper can implement local data cache
© Integrated Computer Solutions, Inc. All Rights Reserved
Model-View-Presenter Pattern
• Wrappers can be an implementation of MVP
• Also called Supervising Controller Pattern
• Provides flexibility between the Model and UI
• Presentation Layer can “reformat” data
• Create strings from multiple model values
• Convert QList<Foo> into an
QAbstractItemModel
© Integrated Computer Solutions, Inc. All Rights Reserved
Model – View Presenter
View
Model
Presenter
Slots
Properties
State
Changed
Get / Set
© Integrated Computer Solutions, Inc. All Rights Reserved
Existing Header
template<class T> class Option
{
public:
T getSetting() const;
void setSetting(T newSetting);
void registerFooCallback(Callback<T>&);
private:
T m_setting;
CallbackCollection<T> m_settingCallbacks;
};
© Integrated Computer Solutions, Inc. All Rights Reserved
Wrapper Header
class DoubleOptionWrapper : public QObject, public
Option<double>
{
Q_OBJECT
Q_PROPERTY(double setting READ getSetting WRITE setSetting
NOTIFY settingChanged)
public:
DoubleOptionWrapper();
signals:
void settingChanged();
private:
void handleSettingCallback(double newSetting);
Callback<double> m_settingCallback;
};
© Integrated Computer Solutions, Inc. All Rights Reserved
Wrapper Source
DoubleOptionWrapper::DoubleOptionWrapper() :
m_settingCallback(this, DoubleOptionWrapper::handleSettingCallback)
{
registerSettingCallback(m_settingCallback);
}
void DoubleOptionWrapper::handleSettingCallback(double newSetting)
{
Q_UNUSED(newSetting)
emit settingChanged();
}
© Integrated Computer Solutions, Inc. All Rights Reserved
Another Wrapper Example
• Issues
• No storage of values in model
• Does not support get function
• Does use QObject and signals
© Integrated Computer Solutions, Inc. All Rights Reserved
Existing Header
class BusData : public QObject
{
Q_OBJECT
public:
void requestSetTargetTemp(double temp);
signals:
void targetTempChanged(double temp);
void error(const QString& errorMessage);
private:
CanBusComm m_canBus;
};
© Integrated Computer Solutions, Inc. All Rights Reserved
Existing Code Structure
BusData TempPanel
void BusData::handleCan()
{
…
emit tempChanged(temp);
}
void setTemp(double temp)
{
m_TempLabel->setText(temp);
}
// UI Label is used for storage!
// Works, but not good design!
Connect()
© Integrated Computer Solutions, Inc. All Rights Reserved
Wrapper Header
class BusDataBridge : public QObject
{
Q_OBJECT
Q_PROPERTY(double targetTemp READ getTargetTemp NOTIFY targetTempChanged)
public:
BusDataBridge(BusData& busData);
double getTargetTemp() const;
Q_INVOKABLE void requestSetTargetTemp(double temp);
signals:
void targetTempChanged();
private slots:
void handleTempTargetChanged(double temp);
private:
BusData& m_busData;
double m_targetTemp;
};
© Integrated Computer Solutions, Inc. All Rights Reserved
Wrapper Source
BusDataBridge::BusDataBridge(BusData& busData) :
m_busData(busData)
{
connect(m_busData, SIGNAL(targetTempChanged(double),
this, SLOT(handleTargetTempChanged(double));
connect(m_busData, SIGNAL(error(QString)),
this, SIGNAL(error(QString)));
}
void BusDataBridge::handleTargetTemperatureChanged(double temp)
{
if(m_temp != temp)
{
m_temp = temp;
emit targetTemperatureChanged();
}
}
© Integrated Computer Solutions, Inc. All Rights Reserved
Wrapper Source
double BusDataBridge::getTargetTemp() const
{
return m_targetTemp;
}
void BusDataBridge::requestSetTargetTemperature(double temp)
{
m_busData.requestSetTargetTemperature(temp);
}
© Integrated Computer Solutions, Inc. All Rights Reserved
Threading Considerations
• BusData example can be useful pattern
• If BusData reads data on another thread
• Sig/Slot connections work across threads
• Qt will dispatch an async event automatically
• Automatic Copy/Lock of data across threads
• Storing data in Bridge object (on GUI thread).
• Good! Avoids locking on read
© Integrated Computer Solutions, Inc. All Rights Reserved
QObject Thread Affinity
• QObjects “belong” to a thread
• Default is the thread that created the QObject
• QObjects can be assigned another thread via
• obj->moveToThread(otherThread)
© Integrated Computer Solutions, Inc. All Rights Reserved
Cross Thread Signals and Slots
• At emit time Qt compares thread ids
• The id of the current thread calling emit signal
• The id the receiver belongs to via obj->thread()
• If the threads are the same slots are called
• If different an event is packaged/posted
© Integrated Computer Solutions, Inc. All Rights Reserved
Cross Thread Signal and Slot
BusBridge
void handleCanData(data)
{
…
emit tempChanged(temp);
}
void handleTempChanged(temp)
{
if(m_temp != temp) {
m_temp = temp;
emit tempChanged();
}
}
BusData
Worker Thread Main Thread
Event Loop
postEvent()
© Integrated Computer Solutions, Inc. All Rights Reserved
Passing Data Across Threads
• Signal parameters across threads
• Need to be QVariant Compatible
• Default constructor
• Assignment Operator
• Copy Constructor
• Q_DECLARE_METATYPE(Type) at end of
Header
• qRegisterMetaType<Type>(“Type”); in Source
© Integrated Computer Solutions, Inc. All Rights Reserved
Implicit Sharing
• When copies are not actually copies
• Most data objects in Qt are implicitly shared
• QString, QList, QMap, QVector, QByteArray, etc
• Implemented w/ thread safe ref counting
• Copy constructor and assignment operator
• Copies an internal pointer and increments the
ref count
© Integrated Computer Solutions, Inc. All Rights Reserved
Exposing C++ Types to QML
• Rather than making 1 CoffeeMaker in main
• Allow QML Programmer to create N CoffeMaker
items
• All of the above applies to exposed types
• Instead of using setContextProperty
• Use qmlRegisterType<>()
© Integrated Computer Solutions, Inc. All Rights Reserved
Expose C++ Types
int main(int argc, char** argv)
{
QGuiApplication app(argc, argv);
qmlRegisterType<CoffeeMaker>(“MrCoffee”,
1, 0,
“CoffeeMaker”);
QQuickView view;
view.setSource(Qurl(“qrc:/main.qml”));
view.show();
return app.exec();
}
© Integrated Computer Solutions, Inc. All Rights Reserved
Expose C++ Types QML
import QtQuick 2.2
import MrCoffee 1.0
Rectangle {
CoffeeMaker { id: maker }
Text {
anchors.centerIn: parent
text: “Coffee Temp” + maker.temp
}
MouseArea {
anchors.fill: parent
onClicked: maker.startBrew(CoffeeMaker.Strong);
}
}
© Integrated Computer Solutions, Inc. All Rights Reserved
Thank You!
Justin Noel
Senior Consulting Engineer
ICS, Inc.

Contenu connexe

Tendances

Qt Internationalization
Qt InternationalizationQt Internationalization
Qt InternationalizationICS
 
Qt multi threads
Qt multi threadsQt multi threads
Qt multi threadsYnon Perek
 
Basics of Model/View Qt programming
Basics of Model/View Qt programmingBasics of Model/View Qt programming
Basics of Model/View Qt programmingICS
 
QThreads: Are You Using Them Wrong?
QThreads: Are You Using Them Wrong? QThreads: Are You Using Them Wrong?
QThreads: Are You Using Them Wrong? ICS
 
Best Practices in Qt Quick/QML - Part III
Best Practices in Qt Quick/QML - Part IIIBest Practices in Qt Quick/QML - Part III
Best Practices in Qt Quick/QML - Part IIIICS
 
Best Practices in Qt Quick/QML - Part 4
Best Practices in Qt Quick/QML - Part 4Best Practices in Qt Quick/QML - Part 4
Best Practices in Qt Quick/QML - Part 4ICS
 
Introduction to the Qt Quick Scene Graph
Introduction to the Qt Quick Scene GraphIntroduction to the Qt Quick Scene Graph
Introduction to the Qt Quick Scene GraphICS
 
Introduction to the Qt State Machine Framework using Qt 6
Introduction to the Qt State Machine Framework using Qt 6Introduction to the Qt State Machine Framework using Qt 6
Introduction to the Qt State Machine Framework using Qt 6ICS
 
Qt for Beginners Part 3 - QML and Qt Quick
Qt for Beginners Part 3 - QML and Qt QuickQt for Beginners Part 3 - QML and Qt Quick
Qt for Beginners Part 3 - QML and Qt QuickICS
 
Practical QML - Key Navigation, Dynamic Language and Theme Change
Practical QML - Key Navigation, Dynamic Language and Theme ChangePractical QML - Key Navigation, Dynamic Language and Theme Change
Practical QML - Key Navigation, Dynamic Language and Theme ChangeBurkhard Stubert
 
Qt Framework Events Signals Threads
Qt Framework Events Signals ThreadsQt Framework Events Signals Threads
Qt Framework Events Signals ThreadsNeera Mital
 
Qt State Machine Framework
Qt State Machine FrameworkQt State Machine Framework
Qt State Machine Frameworkaccount inactive
 
State of the Art OpenGL and Qt
State of the Art OpenGL and QtState of the Art OpenGL and Qt
State of the Art OpenGL and QtICS
 
QVariant, QObject — Qt's not just for GUI development
QVariant, QObject — Qt's not just for GUI developmentQVariant, QObject — Qt's not just for GUI development
QVariant, QObject — Qt's not just for GUI developmentICS
 

Tendances (20)

Qt Internationalization
Qt InternationalizationQt Internationalization
Qt Internationalization
 
Qt multi threads
Qt multi threadsQt multi threads
Qt multi threads
 
Basics of Model/View Qt programming
Basics of Model/View Qt programmingBasics of Model/View Qt programming
Basics of Model/View Qt programming
 
UI Programming with Qt-Quick and QML
UI Programming with Qt-Quick and QMLUI Programming with Qt-Quick and QML
UI Programming with Qt-Quick and QML
 
QThreads: Are You Using Them Wrong?
QThreads: Are You Using Them Wrong? QThreads: Are You Using Them Wrong?
QThreads: Are You Using Them Wrong?
 
Qt Qml
Qt QmlQt Qml
Qt Qml
 
Best Practices in Qt Quick/QML - Part III
Best Practices in Qt Quick/QML - Part IIIBest Practices in Qt Quick/QML - Part III
Best Practices in Qt Quick/QML - Part III
 
Best Practices in Qt Quick/QML - Part 4
Best Practices in Qt Quick/QML - Part 4Best Practices in Qt Quick/QML - Part 4
Best Practices in Qt Quick/QML - Part 4
 
Introduction to the Qt Quick Scene Graph
Introduction to the Qt Quick Scene GraphIntroduction to the Qt Quick Scene Graph
Introduction to the Qt Quick Scene Graph
 
Introduction to the Qt State Machine Framework using Qt 6
Introduction to the Qt State Machine Framework using Qt 6Introduction to the Qt State Machine Framework using Qt 6
Introduction to the Qt State Machine Framework using Qt 6
 
Qt for Beginners Part 3 - QML and Qt Quick
Qt for Beginners Part 3 - QML and Qt QuickQt for Beginners Part 3 - QML and Qt Quick
Qt for Beginners Part 3 - QML and Qt Quick
 
Qt 5 - C++ and Widgets
Qt 5 - C++ and WidgetsQt 5 - C++ and Widgets
Qt 5 - C++ and Widgets
 
Practical QML - Key Navigation, Dynamic Language and Theme Change
Practical QML - Key Navigation, Dynamic Language and Theme ChangePractical QML - Key Navigation, Dynamic Language and Theme Change
Practical QML - Key Navigation, Dynamic Language and Theme Change
 
Hello, QML
Hello, QMLHello, QML
Hello, QML
 
Qt Framework Events Signals Threads
Qt Framework Events Signals ThreadsQt Framework Events Signals Threads
Qt Framework Events Signals Threads
 
Introduction to Qt
Introduction to QtIntroduction to Qt
Introduction to Qt
 
Qt State Machine Framework
Qt State Machine FrameworkQt State Machine Framework
Qt State Machine Framework
 
State of the Art OpenGL and Qt
State of the Art OpenGL and QtState of the Art OpenGL and Qt
State of the Art OpenGL and Qt
 
QVariant, QObject — Qt's not just for GUI development
QVariant, QObject — Qt's not just for GUI developmentQVariant, QObject — Qt's not just for GUI development
QVariant, QObject — Qt's not just for GUI development
 
Qt Application Programming with C++ - Part 2
Qt Application Programming with C++ - Part 2Qt Application Programming with C++ - Part 2
Qt Application Programming with C++ - Part 2
 

Similaire à Best Practices in Qt Quick/QML - Part 3

Porting Motif Applications to Qt - Webinar
Porting Motif Applications to Qt - WebinarPorting Motif Applications to Qt - Webinar
Porting Motif Applications to Qt - WebinarICS
 
Porting Motif Applications to Qt - Webinar
Porting Motif Applications to Qt - WebinarPorting Motif Applications to Qt - Webinar
Porting Motif Applications to Qt - WebinarJanel Heilbrunn
 
Fun with QML
Fun with QMLFun with QML
Fun with QMLICS
 
Plasmaquick Workshop - FISL 13
Plasmaquick Workshop - FISL 13Plasmaquick Workshop - FISL 13
Plasmaquick Workshop - FISL 13Daker Fernandes
 
Practical C++ Generative Programming
Practical C++ Generative ProgrammingPractical C++ Generative Programming
Practical C++ Generative ProgrammingSchalk Cronjé
 
Qt for beginners part 4 doing more
Qt for beginners part 4   doing moreQt for beginners part 4   doing more
Qt for beginners part 4 doing moreICS
 
Objective-C Runtime overview
Objective-C Runtime overviewObjective-C Runtime overview
Objective-C Runtime overviewFantageek
 
Best Practices in Qt Quick/QML - Part 2
Best Practices in Qt Quick/QML - Part 2Best Practices in Qt Quick/QML - Part 2
Best Practices in Qt Quick/QML - Part 2Janel Heilbrunn
 
Best Practices in Qt Quick/QML - Part 2
Best Practices in Qt Quick/QML - Part 2Best Practices in Qt Quick/QML - Part 2
Best Practices in Qt Quick/QML - Part 2ICS
 
Qt for Python
Qt for PythonQt for Python
Qt for PythonICS
 
Qt for beginners part 1 overview and key concepts
Qt for beginners part 1   overview and key conceptsQt for beginners part 1   overview and key concepts
Qt for beginners part 1 overview and key conceptsICS
 
Serving QML applications over the network
Serving QML applications over the networkServing QML applications over the network
Serving QML applications over the networkJeremy Lainé
 
An Effective Approach to Migrate Cassandra Thrift to CQL (Yabin Meng, Pythian...
An Effective Approach to Migrate Cassandra Thrift to CQL (Yabin Meng, Pythian...An Effective Approach to Migrate Cassandra Thrift to CQL (Yabin Meng, Pythian...
An Effective Approach to Migrate Cassandra Thrift to CQL (Yabin Meng, Pythian...DataStax
 
Software Development Best Practices: Separating UI from Business Logic
Software Development Best Practices: Separating UI from Business LogicSoftware Development Best Practices: Separating UI from Business Logic
Software Development Best Practices: Separating UI from Business LogicICS
 
06 - Qt Communication
06 - Qt Communication06 - Qt Communication
06 - Qt CommunicationAndreas Jakl
 
Introduction kubernetes 2017_12_24
Introduction kubernetes 2017_12_24Introduction kubernetes 2017_12_24
Introduction kubernetes 2017_12_24Sam Zheng
 
Integrazione QML / C++
Integrazione QML / C++Integrazione QML / C++
Integrazione QML / C++Paolo Sereno
 

Similaire à Best Practices in Qt Quick/QML - Part 3 (20)

Porting Motif Applications to Qt - Webinar
Porting Motif Applications to Qt - WebinarPorting Motif Applications to Qt - Webinar
Porting Motif Applications to Qt - Webinar
 
Porting Motif Applications to Qt - Webinar
Porting Motif Applications to Qt - WebinarPorting Motif Applications to Qt - Webinar
Porting Motif Applications to Qt - Webinar
 
Fun with QML
Fun with QMLFun with QML
Fun with QML
 
Plasmaquick Workshop - FISL 13
Plasmaquick Workshop - FISL 13Plasmaquick Workshop - FISL 13
Plasmaquick Workshop - FISL 13
 
Practical C++ Generative Programming
Practical C++ Generative ProgrammingPractical C++ Generative Programming
Practical C++ Generative Programming
 
Qt for beginners part 4 doing more
Qt for beginners part 4   doing moreQt for beginners part 4   doing more
Qt for beginners part 4 doing more
 
Objective-C Runtime overview
Objective-C Runtime overviewObjective-C Runtime overview
Objective-C Runtime overview
 
cpp-2013 #18 Qt Part 2
cpp-2013 #18 Qt Part 2cpp-2013 #18 Qt Part 2
cpp-2013 #18 Qt Part 2
 
Best Practices in Qt Quick/QML - Part 2
Best Practices in Qt Quick/QML - Part 2Best Practices in Qt Quick/QML - Part 2
Best Practices in Qt Quick/QML - Part 2
 
Best Practices in Qt Quick/QML - Part 2
Best Practices in Qt Quick/QML - Part 2Best Practices in Qt Quick/QML - Part 2
Best Practices in Qt Quick/QML - Part 2
 
Qt for Python
Qt for PythonQt for Python
Qt for Python
 
Qt for beginners part 1 overview and key concepts
Qt for beginners part 1   overview and key conceptsQt for beginners part 1   overview and key concepts
Qt for beginners part 1 overview and key concepts
 
Serving QML applications over the network
Serving QML applications over the networkServing QML applications over the network
Serving QML applications over the network
 
QtQuick Day 4
QtQuick Day 4QtQuick Day 4
QtQuick Day 4
 
An Effective Approach to Migrate Cassandra Thrift to CQL (Yabin Meng, Pythian...
An Effective Approach to Migrate Cassandra Thrift to CQL (Yabin Meng, Pythian...An Effective Approach to Migrate Cassandra Thrift to CQL (Yabin Meng, Pythian...
An Effective Approach to Migrate Cassandra Thrift to CQL (Yabin Meng, Pythian...
 
Software Development Best Practices: Separating UI from Business Logic
Software Development Best Practices: Separating UI from Business LogicSoftware Development Best Practices: Separating UI from Business Logic
Software Development Best Practices: Separating UI from Business Logic
 
06 - Qt Communication
06 - Qt Communication06 - Qt Communication
06 - Qt Communication
 
Introduction kubernetes 2017_12_24
Introduction kubernetes 2017_12_24Introduction kubernetes 2017_12_24
Introduction kubernetes 2017_12_24
 
Integrazione QML / C++
Integrazione QML / C++Integrazione QML / C++
Integrazione QML / C++
 
Qt programming-using-cpp
Qt programming-using-cppQt programming-using-cpp
Qt programming-using-cpp
 

Plus de ICS

The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...ICS
 
Practical Advice for FDA’s 510(k) Requirements.pdf
Practical Advice for FDA’s 510(k) Requirements.pdfPractical Advice for FDA’s 510(k) Requirements.pdf
Practical Advice for FDA’s 510(k) Requirements.pdfICS
 
Accelerating Development of a Safety-Critical Cobot Welding System with Qt/QM...
Accelerating Development of a Safety-Critical Cobot Welding System with Qt/QM...Accelerating Development of a Safety-Critical Cobot Welding System with Qt/QM...
Accelerating Development of a Safety-Critical Cobot Welding System with Qt/QM...ICS
 
Overcoming CMake Configuration Issues Webinar
Overcoming CMake Configuration Issues WebinarOvercoming CMake Configuration Issues Webinar
Overcoming CMake Configuration Issues WebinarICS
 
Enhancing Quality and Test in Medical Device Design - Part 2.pdf
Enhancing Quality and Test in Medical Device Design - Part 2.pdfEnhancing Quality and Test in Medical Device Design - Part 2.pdf
Enhancing Quality and Test in Medical Device Design - Part 2.pdfICS
 
Designing and Managing IoT Devices for Rapid Deployment - Webinar.pdf
Designing and Managing IoT Devices for Rapid Deployment - Webinar.pdfDesigning and Managing IoT Devices for Rapid Deployment - Webinar.pdf
Designing and Managing IoT Devices for Rapid Deployment - Webinar.pdfICS
 
Quality and Test in Medical Device Design - Part 1.pdf
Quality and Test in Medical Device Design - Part 1.pdfQuality and Test in Medical Device Design - Part 1.pdf
Quality and Test in Medical Device Design - Part 1.pdfICS
 
Creating Digital Twins Using Rapid Development Techniques.pdf
Creating Digital Twins Using Rapid Development Techniques.pdfCreating Digital Twins Using Rapid Development Techniques.pdf
Creating Digital Twins Using Rapid Development Techniques.pdfICS
 
Secure Your Medical Devices From the Ground Up
Secure Your Medical Devices From the Ground Up Secure Your Medical Devices From the Ground Up
Secure Your Medical Devices From the Ground Up ICS
 
Cybersecurity and Software Updates in Medical Devices.pdf
Cybersecurity and Software Updates in Medical Devices.pdfCybersecurity and Software Updates in Medical Devices.pdf
Cybersecurity and Software Updates in Medical Devices.pdfICS
 
MDG Panel - Creating Expert Level GUIs for Complex Medical Devices
MDG Panel - Creating Expert Level GUIs for Complex Medical DevicesMDG Panel - Creating Expert Level GUIs for Complex Medical Devices
MDG Panel - Creating Expert Level GUIs for Complex Medical DevicesICS
 
How to Craft a Winning IOT Device Management Solution
How to Craft a Winning IOT Device Management SolutionHow to Craft a Winning IOT Device Management Solution
How to Craft a Winning IOT Device Management SolutionICS
 
Bridging the Gap Between Development and Regulatory Teams
Bridging the Gap Between Development and Regulatory TeamsBridging the Gap Between Development and Regulatory Teams
Bridging the Gap Between Development and Regulatory TeamsICS
 
IoT Device Fleet Management: Create a Robust Solution with Azure
IoT Device Fleet Management: Create a Robust Solution with AzureIoT Device Fleet Management: Create a Robust Solution with Azure
IoT Device Fleet Management: Create a Robust Solution with AzureICS
 
Basic Cmake for Qt Users
Basic Cmake for Qt UsersBasic Cmake for Qt Users
Basic Cmake for Qt UsersICS
 
Software Update Mechanisms: Selecting the Best Solutin for Your Embedded Linu...
Software Update Mechanisms: Selecting the Best Solutin for Your Embedded Linu...Software Update Mechanisms: Selecting the Best Solutin for Your Embedded Linu...
Software Update Mechanisms: Selecting the Best Solutin for Your Embedded Linu...ICS
 
Qt Installer Framework
Qt Installer FrameworkQt Installer Framework
Qt Installer FrameworkICS
 
Bridging the Gap Between Development and Regulatory Teams
Bridging the Gap Between Development and Regulatory TeamsBridging the Gap Between Development and Regulatory Teams
Bridging the Gap Between Development and Regulatory TeamsICS
 
Overcome Hardware And Software Challenges - Medical Device Case Study
Overcome Hardware And Software Challenges - Medical Device Case StudyOvercome Hardware And Software Challenges - Medical Device Case Study
Overcome Hardware And Software Challenges - Medical Device Case StudyICS
 
User Experience Design for IoT
User Experience Design for IoTUser Experience Design for IoT
User Experience Design for IoTICS
 

Plus de ICS (20)

The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
 
Practical Advice for FDA’s 510(k) Requirements.pdf
Practical Advice for FDA’s 510(k) Requirements.pdfPractical Advice for FDA’s 510(k) Requirements.pdf
Practical Advice for FDA’s 510(k) Requirements.pdf
 
Accelerating Development of a Safety-Critical Cobot Welding System with Qt/QM...
Accelerating Development of a Safety-Critical Cobot Welding System with Qt/QM...Accelerating Development of a Safety-Critical Cobot Welding System with Qt/QM...
Accelerating Development of a Safety-Critical Cobot Welding System with Qt/QM...
 
Overcoming CMake Configuration Issues Webinar
Overcoming CMake Configuration Issues WebinarOvercoming CMake Configuration Issues Webinar
Overcoming CMake Configuration Issues Webinar
 
Enhancing Quality and Test in Medical Device Design - Part 2.pdf
Enhancing Quality and Test in Medical Device Design - Part 2.pdfEnhancing Quality and Test in Medical Device Design - Part 2.pdf
Enhancing Quality and Test in Medical Device Design - Part 2.pdf
 
Designing and Managing IoT Devices for Rapid Deployment - Webinar.pdf
Designing and Managing IoT Devices for Rapid Deployment - Webinar.pdfDesigning and Managing IoT Devices for Rapid Deployment - Webinar.pdf
Designing and Managing IoT Devices for Rapid Deployment - Webinar.pdf
 
Quality and Test in Medical Device Design - Part 1.pdf
Quality and Test in Medical Device Design - Part 1.pdfQuality and Test in Medical Device Design - Part 1.pdf
Quality and Test in Medical Device Design - Part 1.pdf
 
Creating Digital Twins Using Rapid Development Techniques.pdf
Creating Digital Twins Using Rapid Development Techniques.pdfCreating Digital Twins Using Rapid Development Techniques.pdf
Creating Digital Twins Using Rapid Development Techniques.pdf
 
Secure Your Medical Devices From the Ground Up
Secure Your Medical Devices From the Ground Up Secure Your Medical Devices From the Ground Up
Secure Your Medical Devices From the Ground Up
 
Cybersecurity and Software Updates in Medical Devices.pdf
Cybersecurity and Software Updates in Medical Devices.pdfCybersecurity and Software Updates in Medical Devices.pdf
Cybersecurity and Software Updates in Medical Devices.pdf
 
MDG Panel - Creating Expert Level GUIs for Complex Medical Devices
MDG Panel - Creating Expert Level GUIs for Complex Medical DevicesMDG Panel - Creating Expert Level GUIs for Complex Medical Devices
MDG Panel - Creating Expert Level GUIs for Complex Medical Devices
 
How to Craft a Winning IOT Device Management Solution
How to Craft a Winning IOT Device Management SolutionHow to Craft a Winning IOT Device Management Solution
How to Craft a Winning IOT Device Management Solution
 
Bridging the Gap Between Development and Regulatory Teams
Bridging the Gap Between Development and Regulatory TeamsBridging the Gap Between Development and Regulatory Teams
Bridging the Gap Between Development and Regulatory Teams
 
IoT Device Fleet Management: Create a Robust Solution with Azure
IoT Device Fleet Management: Create a Robust Solution with AzureIoT Device Fleet Management: Create a Robust Solution with Azure
IoT Device Fleet Management: Create a Robust Solution with Azure
 
Basic Cmake for Qt Users
Basic Cmake for Qt UsersBasic Cmake for Qt Users
Basic Cmake for Qt Users
 
Software Update Mechanisms: Selecting the Best Solutin for Your Embedded Linu...
Software Update Mechanisms: Selecting the Best Solutin for Your Embedded Linu...Software Update Mechanisms: Selecting the Best Solutin for Your Embedded Linu...
Software Update Mechanisms: Selecting the Best Solutin for Your Embedded Linu...
 
Qt Installer Framework
Qt Installer FrameworkQt Installer Framework
Qt Installer Framework
 
Bridging the Gap Between Development and Regulatory Teams
Bridging the Gap Between Development and Regulatory TeamsBridging the Gap Between Development and Regulatory Teams
Bridging the Gap Between Development and Regulatory Teams
 
Overcome Hardware And Software Challenges - Medical Device Case Study
Overcome Hardware And Software Challenges - Medical Device Case StudyOvercome Hardware And Software Challenges - Medical Device Case Study
Overcome Hardware And Software Challenges - Medical Device Case Study
 
User Experience Design for IoT
User Experience Design for IoTUser Experience Design for IoT
User Experience Design for IoT
 

Dernier

Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsAlberto González Trastoy
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providermohitmore19
 
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesAI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesVictorSzoltysek
 
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...kalichargn70th171
 
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...OnePlan Solutions
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVshikhaohhpro
 
Exploring the Best Video Editing App.pdf
Exploring the Best Video Editing App.pdfExploring the Best Video Editing App.pdf
Exploring the Best Video Editing App.pdfproinshot.com
 
AI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplateAI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplatePresentation.STUDIO
 
10 Trends Likely to Shape Enterprise Technology in 2024
10 Trends Likely to Shape Enterprise Technology in 202410 Trends Likely to Shape Enterprise Technology in 2024
10 Trends Likely to Shape Enterprise Technology in 2024Mind IT Systems
 
Azure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdf
Azure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdfAzure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdf
Azure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdfryanfarris8
 
Diamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionDiamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionSolGuruz
 
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerHow To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerThousandEyes
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Modelsaagamshah0812
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfkalichargn70th171
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfkalichargn70th171
 
Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) SolutionIntroducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) SolutionOnePlan Solutions
 
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
Direct Style Effect Systems -The Print[A] Example- A Comprehension AidDirect Style Effect Systems -The Print[A] Example- A Comprehension Aid
Direct Style Effect Systems - The Print[A] Example - A Comprehension AidPhilip Schwarz
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comFatema Valibhai
 
Define the academic and professional writing..pdf
Define the academic and professional writing..pdfDefine the academic and professional writing..pdf
Define the academic and professional writing..pdfPearlKirahMaeRagusta1
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️Delhi Call girls
 

Dernier (20)

Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
 
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesAI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
 
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
 
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTV
 
Exploring the Best Video Editing App.pdf
Exploring the Best Video Editing App.pdfExploring the Best Video Editing App.pdf
Exploring the Best Video Editing App.pdf
 
AI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplateAI & Machine Learning Presentation Template
AI & Machine Learning Presentation Template
 
10 Trends Likely to Shape Enterprise Technology in 2024
10 Trends Likely to Shape Enterprise Technology in 202410 Trends Likely to Shape Enterprise Technology in 2024
10 Trends Likely to Shape Enterprise Technology in 2024
 
Azure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdf
Azure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdfAzure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdf
Azure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdf
 
Diamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionDiamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with Precision
 
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerHow To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Models
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
 
Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) SolutionIntroducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
 
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
Direct Style Effect Systems -The Print[A] Example- A Comprehension AidDirect Style Effect Systems -The Print[A] Example- A Comprehension Aid
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.com
 
Define the academic and professional writing..pdf
Define the academic and professional writing..pdfDefine the academic and professional writing..pdf
Define the academic and professional writing..pdf
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 

Best Practices in Qt Quick/QML - Part 3

  • 1. © Integrated Computer Solutions, Inc. All Rights Reserved Best Practices in Qt Quick/QML Part 3 Justin Noel Senior Consulting Engineer ICS, Inc.
  • 2. © Integrated Computer Solutions, Inc. All Rights Reserved Agenda • C++ / QML Integration • Reusing Existing C++ Code
  • 3. © Integrated Computer Solutions, Inc. All Rights Reserved Using C++ and QML
  • 4. © Integrated Computer Solutions, Inc. All Rights Reserved Drive QML with C++
  • 5. © Integrated Computer Solutions, Inc. All Rights Reserved Model – View Pattern • C++ code can know nothing about the UI • Properties, Slots and Signals are the interface in QML • QML Items connect or bind to C++ Objects • Good Design is Enforced • C++ cannot depend on UI • Avoids “accidental” storage of data inside UI components • C++ is more portable to other UI frameworks
  • 6. © Integrated Computer Solutions, Inc. All Rights Reserved C++ Integration Techniques • Expose object instances from C++ to QML • Objects appear as global variables to QML • Effectively singletons • Expose C++ types to QML • New types are available for QML programmers to use • Remember how Rectangle and Text are actually C++?
  • 7. © Integrated Computer Solutions, Inc. All Rights Reserved Creating Properties in C++ • Properties are the combination of • Read function • Write function • Notify signal • Signals/slots is Qt’s object communication system
  • 8. © Integrated Computer Solutions, Inc. All Rights Reserved Creating Properties in C++ • Inherit from QObject • Use the Q_OBJECT macro • Use the Q_PROPERTY macro
  • 9. © Integrated Computer Solutions, Inc. All Rights Reserved C++ Property Header class CoffeeMaker : public QObject { Q_OBJECT Q_PROPERTY(int temp READ getTemp WRITE setTemp NOTIFY tempChanged) public: int getTemp() const; void setTemp(int temp); signals: void tempChanged(); // Parameter is not required by QtQuick private: int m_temp; };
  • 10. © Integrated Computer Solutions, Inc. All Rights Reserved Source is as usual int CoffeeMaker ::getTemp() const { return m_temp; } void CoffeeMaker ::setTemp(int temp) { if(m_temp != temp) { m_temp = temp; emit tempChanged(); } }
  • 11. © Integrated Computer Solutions, Inc. All Rights Reserved Invokable C++ Methods • Methods can be called from QML • Any slot can be called • Any Q_INVOKABLE can be called
  • 12. © Integrated Computer Solutions, Inc. All Rights Reserved Invokable C++ Return Types • Any basic Qt or C++ type • int, double, QString, etc • Any returned QObject* belongs to QML • Will be deleted by QML during GC • NOTE: QObject* returned from a Q_PROPERTY belongs to C++
  • 13. © Integrated Computer Solutions, Inc. All Rights Reserved Invokable C++ Functions class CoffeeMaker : public QObject { Q_OBJECT Q_PROPERTY(int temp READ getTemp WRITE setTemp NOTIFY tempChanged) public: int getTemp() const; void setTemp(int temp); Q_INVOKABLE void startBrew(); public slots: void stopBrew(); signals: void tempChanged(); //Using a parameter is not required by QtQuick };
  • 14. © Integrated Computer Solutions, Inc. All Rights Reserved Exposing Instances int main(int argc, char** argv) { QGuiApplication app(argc, argv); CoffeeMaker maker; QQuickView view; view.rootContext()->setContextProperty(“maker”, &maker); view.setSource(Qurl(“qrc:/main.qml”)); view.show(); return app.exec(); }
  • 15. © Integrated Computer Solutions, Inc. All Rights Reserved Basic C++ Integration QML import QtQuick 2.2 Rectangle { width: 1024 height: 768 Text { anchors.centerIn: parent text: “Coffee Temp” + maker.temp } MouseArea { anchors.fill: parent onClicked: maker.startBrew(); } }
  • 16. © Integrated Computer Solutions, Inc. All Rights Reserved Complex Properties • QObject* can be used as a property • Used for encapsulation and creating trees of properties • Properties can have properties!
  • 17. © Integrated Computer Solutions, Inc. All Rights Reserved Complex Properties Header class CoffeeMaker : public QObject { Q_OBJECT Q_PROPERTY(QObject* options READ getOptions CONSTANT) public: QObject* getOptions() const { return &m_options; }; Q_INVOKABLE void startBrew(); private: Options m_options; };
  • 18. © Integrated Computer Solutions, Inc. All Rights Reserved Complex Properties Header class Options: public QObject { Q_OBJECT Q_PROPERTY(int temp READ getTemp WRITE setTemp NOTIFY tempChanged) public: int getTemp() const; void setTemp(int temp); signals: void tempChanged(); };
  • 19. © Integrated Computer Solutions, Inc. All Rights Reserved Complex Properties QML import QtQuick 2.2 Rectangle { width: 1024 height: 768 Text { anchors.centerIn: parent text: “Coffee temp” + maker.options.temp } MouseArea { anchors.fill: parent onClicked: maker.startBrew(); } }
  • 20. © Integrated Computer Solutions, Inc. All Rights Reserved Enum Properties • C++ enums can be used as QML types • Use Q_ENUMS macro • Use qmlRegisterUncreatableType<>(…) • Package Name • Major Version • Minor Version • Type Name • Error Message
  • 21. © Integrated Computer Solutions, Inc. All Rights Reserved Enum Properties Header class CoffeeMaker: public QObject { Q_OBJECT Q_PROPERTY(Strength strength READ getStrength WRITE setStrength NOTIFY strengthChanged) public: CoffeeMaker(); enum Strength { Light, Medium, Dark }; Q_ENUM(Strength) Strength getStrength() const; void setStrength(Strength newStrength); signals: void strengthChanged(); };
  • 22. © Integrated Computer Solutions, Inc. All Rights Reserved Enum Properties Source CoffeeMaker::CoffeeMaker() { qmlRegisterUncreatableType<CoffeeMaker>(“MrCoffee”, 1, 0, “CoffeeMaker”, “Do not instance.”); }
  • 23. © Integrated Computer Solutions, Inc. All Rights Reserved Enum Properties QML import QtQuick 2.2 import MrCoffee 1.0 //Needed to get TypeInfo for CoffeeMaker Rectangle { width: 1024 height: 768 Text { anchors.centerIn: parent text:textFromStrength(maker.strength)//Evaluated as int } function textFromStrength(strength) { … } MouseArea { anchors.fill: parent onClicked: maker.startBrew(CoffeeMaker.Strong); //Used by name } }
  • 24. © Integrated Computer Solutions, Inc. All Rights Reserved Reusing Existing Code • QML requires that properties • READ functions returns correct value • Could be called anytime • NOTIFY signal emitted when prop changes • Immediate call to READ returns new changed value
  • 25. © Integrated Computer Solutions, Inc. All Rights Reserved Reuse Techniques • Direct – Add Q_PROPERTY • Model is already QObject based • Stores its own data • Wrapper – Write a new QObject class • Model is not (or cannot be) QObject based • Model does not store data
  • 26. © Integrated Computer Solutions, Inc. All Rights Reserved Direct Reuse Technique • Use Q_PROPERTY with existing • READ function • WRITE function (optional) • NOTIFY signal • Use Q_INVOKABLE on existing methods • Functions you want callable from the UI
  • 27. © Integrated Computer Solutions, Inc. All Rights Reserved Existing Header class CoffeeMaker : public QObject { Q_OBJECT public: float targetTemp() const; void setTargetTemp(float taregetTemp); float temp() const; signals: void targetTempChanged(float targetTemp); void tempChanged(float temp); private: … //Members };
  • 28. © Integrated Computer Solutions, Inc. All Rights Reserved Direct Reuse Header class CoffeeMaker : public QObject { Q_OBJECT Q_PROPERTY(float targetTemp READ targetTemp NOTIFY targetTempChanged) Q_PROPERTY(float temp READ temp NOTIFY tempChanged public: float targetTemp() const; Q_INVOKABLE void setTargetTemp(float taregetTemp); float temp() const; signals: void targetTempChanged(float targetTemp); void tempChanged(float temp); ... };
  • 29. © Integrated Computer Solutions, Inc. All Rights Reserved Read Only Properties • Properties can be read-only • Slots or Q_INVOKABLE functions • Can change state and emit signals • Sometimes it’s cleaner to have • Read only properties • Q_INVOKABLE setter functions
  • 30. © Integrated Computer Solutions, Inc. All Rights Reserved Direct Reuse Issues • Inherited NOTIFY signals compile error • NOTIFY signal needs be in the same class as Q_PROPERTY declaration • Workaround: • Specify new signal in subclass • Use SIGNAL – SIGNAL connection in ctor
  • 31. © Integrated Computer Solutions, Inc. All Rights Reserved Wrapper Reuse Technique • Class that provides the QObject interface • Inheritance • Composition – Easier to test • Less chance of “rocking the boat” • More typing. More code
  • 32. © Integrated Computer Solutions, Inc. All Rights Reserved Wrappers fix a lot of issues • Class is template based • Can’t directly inherit Qobject • Class does not use signals • Uses some other callback mechanism • Class does not follow get/set/notify pattern • Wrapper can implement local data cache
  • 33. © Integrated Computer Solutions, Inc. All Rights Reserved Model-View-Presenter Pattern • Wrappers can be an implementation of MVP • Also called Supervising Controller Pattern • Provides flexibility between the Model and UI • Presentation Layer can “reformat” data • Create strings from multiple model values • Convert QList<Foo> into an QAbstractItemModel
  • 34. © Integrated Computer Solutions, Inc. All Rights Reserved Model – View Presenter View Model Presenter Slots Properties State Changed Get / Set
  • 35. © Integrated Computer Solutions, Inc. All Rights Reserved Existing Header template<class T> class Option { public: T getSetting() const; void setSetting(T newSetting); void registerFooCallback(Callback<T>&); private: T m_setting; CallbackCollection<T> m_settingCallbacks; };
  • 36. © Integrated Computer Solutions, Inc. All Rights Reserved Wrapper Header class DoubleOptionWrapper : public QObject, public Option<double> { Q_OBJECT Q_PROPERTY(double setting READ getSetting WRITE setSetting NOTIFY settingChanged) public: DoubleOptionWrapper(); signals: void settingChanged(); private: void handleSettingCallback(double newSetting); Callback<double> m_settingCallback; };
  • 37. © Integrated Computer Solutions, Inc. All Rights Reserved Wrapper Source DoubleOptionWrapper::DoubleOptionWrapper() : m_settingCallback(this, DoubleOptionWrapper::handleSettingCallback) { registerSettingCallback(m_settingCallback); } void DoubleOptionWrapper::handleSettingCallback(double newSetting) { Q_UNUSED(newSetting) emit settingChanged(); }
  • 38. © Integrated Computer Solutions, Inc. All Rights Reserved Another Wrapper Example • Issues • No storage of values in model • Does not support get function • Does use QObject and signals
  • 39. © Integrated Computer Solutions, Inc. All Rights Reserved Existing Header class BusData : public QObject { Q_OBJECT public: void requestSetTargetTemp(double temp); signals: void targetTempChanged(double temp); void error(const QString& errorMessage); private: CanBusComm m_canBus; };
  • 40. © Integrated Computer Solutions, Inc. All Rights Reserved Existing Code Structure BusData TempPanel void BusData::handleCan() { … emit tempChanged(temp); } void setTemp(double temp) { m_TempLabel->setText(temp); } // UI Label is used for storage! // Works, but not good design! Connect()
  • 41. © Integrated Computer Solutions, Inc. All Rights Reserved Wrapper Header class BusDataBridge : public QObject { Q_OBJECT Q_PROPERTY(double targetTemp READ getTargetTemp NOTIFY targetTempChanged) public: BusDataBridge(BusData& busData); double getTargetTemp() const; Q_INVOKABLE void requestSetTargetTemp(double temp); signals: void targetTempChanged(); private slots: void handleTempTargetChanged(double temp); private: BusData& m_busData; double m_targetTemp; };
  • 42. © Integrated Computer Solutions, Inc. All Rights Reserved Wrapper Source BusDataBridge::BusDataBridge(BusData& busData) : m_busData(busData) { connect(m_busData, SIGNAL(targetTempChanged(double), this, SLOT(handleTargetTempChanged(double)); connect(m_busData, SIGNAL(error(QString)), this, SIGNAL(error(QString))); } void BusDataBridge::handleTargetTemperatureChanged(double temp) { if(m_temp != temp) { m_temp = temp; emit targetTemperatureChanged(); } }
  • 43. © Integrated Computer Solutions, Inc. All Rights Reserved Wrapper Source double BusDataBridge::getTargetTemp() const { return m_targetTemp; } void BusDataBridge::requestSetTargetTemperature(double temp) { m_busData.requestSetTargetTemperature(temp); }
  • 44. © Integrated Computer Solutions, Inc. All Rights Reserved Threading Considerations • BusData example can be useful pattern • If BusData reads data on another thread • Sig/Slot connections work across threads • Qt will dispatch an async event automatically • Automatic Copy/Lock of data across threads • Storing data in Bridge object (on GUI thread). • Good! Avoids locking on read
  • 45. © Integrated Computer Solutions, Inc. All Rights Reserved QObject Thread Affinity • QObjects “belong” to a thread • Default is the thread that created the QObject • QObjects can be assigned another thread via • obj->moveToThread(otherThread)
  • 46. © Integrated Computer Solutions, Inc. All Rights Reserved Cross Thread Signals and Slots • At emit time Qt compares thread ids • The id of the current thread calling emit signal • The id the receiver belongs to via obj->thread() • If the threads are the same slots are called • If different an event is packaged/posted
  • 47. © Integrated Computer Solutions, Inc. All Rights Reserved Cross Thread Signal and Slot BusBridge void handleCanData(data) { … emit tempChanged(temp); } void handleTempChanged(temp) { if(m_temp != temp) { m_temp = temp; emit tempChanged(); } } BusData Worker Thread Main Thread Event Loop postEvent()
  • 48. © Integrated Computer Solutions, Inc. All Rights Reserved Passing Data Across Threads • Signal parameters across threads • Need to be QVariant Compatible • Default constructor • Assignment Operator • Copy Constructor • Q_DECLARE_METATYPE(Type) at end of Header • qRegisterMetaType<Type>(“Type”); in Source
  • 49. © Integrated Computer Solutions, Inc. All Rights Reserved Implicit Sharing • When copies are not actually copies • Most data objects in Qt are implicitly shared • QString, QList, QMap, QVector, QByteArray, etc • Implemented w/ thread safe ref counting • Copy constructor and assignment operator • Copies an internal pointer and increments the ref count
  • 50. © Integrated Computer Solutions, Inc. All Rights Reserved Exposing C++ Types to QML • Rather than making 1 CoffeeMaker in main • Allow QML Programmer to create N CoffeMaker items • All of the above applies to exposed types • Instead of using setContextProperty • Use qmlRegisterType<>()
  • 51. © Integrated Computer Solutions, Inc. All Rights Reserved Expose C++ Types int main(int argc, char** argv) { QGuiApplication app(argc, argv); qmlRegisterType<CoffeeMaker>(“MrCoffee”, 1, 0, “CoffeeMaker”); QQuickView view; view.setSource(Qurl(“qrc:/main.qml”)); view.show(); return app.exec(); }
  • 52. © Integrated Computer Solutions, Inc. All Rights Reserved Expose C++ Types QML import QtQuick 2.2 import MrCoffee 1.0 Rectangle { CoffeeMaker { id: maker } Text { anchors.centerIn: parent text: “Coffee Temp” + maker.temp } MouseArea { anchors.fill: parent onClicked: maker.startBrew(CoffeeMaker.Strong); } }
  • 53. © Integrated Computer Solutions, Inc. All Rights Reserved Thank You! Justin Noel Senior Consulting Engineer ICS, Inc.