SlideShare ist ein Scribd-Unternehmen logo
1 von 42
Downloaden Sie, um offline zu lesen
Qt For Beginners - Part 4
Doing More
Christopher Probst, Qt Consultant
Integrated Computer Solutions
Visit us at http://www.ics.com
Video Available at: http://bit.ly/qt-beginners-part-4-more
Copyright 2016, Integrated Computers Solutions, Inc.
This work may not be reproduced in whole or in part without the express written consent of
Integrated Computer Solutions, Inc.
1
● Using Qt Creator
● Model/View
● Localization
● Integrating QML With C++
● Embedded Development
● Best Practices
● Tips and Tricks
● Where To Go Next
● Q&A
Agenda
2
● Using Qt Creator
● Model/View
● Localization
● Integrating QML With C++
● Embedded Development
● Best Practices
● Tips and Tricks
● Where To Go Next
● Q&A
Agenda
3
Qt Creator Kit
4
A kit consists of:
● Qt version (path to qmake)
● Debugger
● Compiler
● Target platform
● Build configuration (Qt
mkspec)
● Other environment specs
Kit Selection
● A Qt Creator user can navigate across multiple kits
● Facilitates the management of multiple Qt versions, compilers, debuggers
● Ideal cross compilation and deployment to other devices
5
Project Configuration
Tabs for each project (kit), build and run settings:
6
Ctrl + [1-7]: Switch between various screens
● Welcome Screen
● Edit Mode
● Debug
● etc
Alt + [0-4]: Toggle which output panes are visible
● Sidebar
● Build Issues
● Search Results
● Application Output
● Compile Output
F2: Follow the highlighted symbol
Ctrl + i: Auto-indent selected code
Ctrl + /: Comment selected code
Ctrl + tab: Navigate through the files
Shortcuts
7
Shortcuts
Specifying your own shortcut keys!
8
Fake Vim
If you miss Vim!
9
● Using Qt Creator
● Model/View
● Localization
● Integrating QML With C++
● Embedded Development
● Best Practices
● Tips and Tricks
● Where To Go Next
● Q&A
Agenda
10
What is Model/View?
● A design pattern that aims to separate
implementation of the visual interface from the
business logic that drives it.
● This design pattern is common throughout Qt.
○ Integration of UI files (Qt Designer)
○ Loading of QML files
○ Item-View Classes
11
Item-View and Model/View Classes
● To display large sets of indexed data, Qt
provides a Model/View architecture:
Model/View/Delegate
● The views are provided by convenience
classes
12
QTableView
QTreeView
Model Classes
● The preceding views are given a model
● Qt provides base model classes that the
programmer generally subclasses.
○ QAbstractItemModel
○ QAbstractListModel
○ QAbstractTableModel
13
ui->DownloadTable->setModel(downloadModel);
void QAbstractItemView::setModel(QAbstractItemModel * model)
Model/View Example
We want to create an iTunes/Napster-like
download tool that concurrently downloads
multiple files:
14
Download Manager UI Example
Model Class Example
class DownloadsModel : public QAbstractTableModel
{
Q_OBJECT
public:
DownloadsModel(QObject *parent = 0);
// QAbstractItemModel interface
int rowCount(const QModelIndex &parent = QModelIndex()) const;
int columnCount(const QModelIndex &parent = QModelIndex()) const;
QVariant data(const QModelIndex &index, int role) const;
QVariant headerData(int section, Qt::Orientation orientation, int role) const;
...
private:
// Our model “knows” how to access the data for the view
QList<Downloads*> DownLoadList;
};
15
Model Talking to the View
QVariant DownloadsModel::data(const QModelIndex &index, int role) const
{
if (role == Qt::DisplayRole) {
// Data for first column
if (index.column() == 0) {
// Data for view
QUrl url = DownLoadList.at(index.row())->url();
return url;
}
// Data for second column
else if (index.column() == 1) {
// Data for view
int progressPercentage = (DownLoadList.at(index.row())->progress() * 100 /
DownLoadList.at(index.row())->total());
return progressPercentage;
}
}
return QVariant();
}
16
Through the QAbstractItemModel::data(..) function, the model,
given a row and a column, returns the appropriate data
The Delegate
● If the view provided by Qt does not display the
data visually as desired, we implement a
delegate
● The delegate class is used to specify how data
is rendered by the view
● Instead of displaying a number, we want to
display a progress bar
17
Delegate Implementation
void ProgressBarDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const
QModelIndex &index) const
{
if (index.column() == 1) {
int progressPercentage = index.model()->data(index, Qt::DisplayRole).toInt();
QStyleOptionProgressBar progressBarOption;
progressBarOption.rect = QRect(option.rect.x() + 5, option.rect.y() + 5, option.rect.width()
- 10, option.rect.height() - 10);
progressBarOption.minimum = 0;
progressBarOption.maximum = 100;
progressBarOption.progress = progressPercentage;
progressBarOption.text= QString::number(progressPercentage) + "%";
progressBarOption.textAlignment = Qt::AlignCenter;
progressBarOption.textVisible = true;
if (option.state & QStyle::State_Selected)
painter->fillRect(option.rect, option.palette.alternateBase());
QApplication::style()->drawControl( QStyle::CE_ProgressBar, &progressBarOption, painter);
} else {
QStyledItemDelegate::paint(painter, option, index);
}
}
18
ProgressBarDelegate* delegate = new ProgressBarDelegate(this);
ui->DownloadTable->setItemDelegateForColumn( 1, delegate);
● Using Qt Creator
● Model/View
● Localization
● Integrating QML With C++
● Embedded Development
● Best Practices
● Tips and Tricks
● Where To Go Next
● Q&A
Agenda
19
Localization
20
Code
label->setText(tr("Greeting"));
Tool
lupdate Project File (app.pro)
TRANSLATIONS += app_de.ts CODECFORTR =
UTF-8
Tool
Qt Linguist
TS File
app_de.ts
Tool
lrelease
QM File
app_de.qm
Code
QTranslator translator; translator.
load("app_de"); app.installTranslator
(&translator);
provide translation
2
load translation
4
extracts translations
updates ts file
compile translation
3
1
Localization
In C++:
QString s = tr("Text String");
setWindowTitle(tr("File: %1 Line: %2").arg(f).arg(l));
//: This comment is seen by translation staff
label->setText(tr("Name: %1 Date: %2").arg(name, d.toString()));
21
In QML:
Button {
id: button1
text: qsTr("Press Me")
}
● Using Qt Creator
● Model/View
● Localization
● Integrating QML With C++
● Embedded Development
● Best Practices
● Tips and Tricks
● Where To Go Next
● Q&A
Agenda
22
Loading the QML File
#include <QGuiApplication>
#include <QQmlApplicationEngine>
int main(int argc, char *argv[])
{
QGuiApplication app(argc, argv);
QQmlApplicationEngine engine;
engine.load(QUrl("qrc:/main.qml"));
return app.exec();
}
23
QT += qml quick
CONFIG += c++11
SOURCES += main.cpp
RESOURCES += qml.qrc
In the .pro file...
In the main.cpp file...
Exporting C++ Objects to QML
class Message : public QObject
{
Q_OBJECT
Q_PROPERTY(QString author READ author WRITE setAuthor NOTIFY authorChanged)
Q_PROPERTY(QDateTime creationDate READ creationDate WRITE setCreationDate NOTIFY
creationDateChanged)
public:
// ...
};
24
qmlRegisterType<Message>("com.mycompany.messaging", 1, 0, "Message");
import com.mycompany.messaging 1.0
Message {
author: "Amelie"
creationDate: new Date()
}
Exported file In header file
Registering the class in the code before the QML is loaded
Using class in QML file
Alternate Way of Exporting C++ Object
#include "user.h"
#include <QApplication>
void main(int argc, char* argv[])
{
QApplication app(argc, argv);
qmlRegisterType<User>("com.mycompany.qmlcomponents", 1, 0, "User");
User *currentUser = new User("Alice", 29);
QQuickView *view = new QQuickView;
QQmlContext *context = view->engine()->rootContext();
// Exporting of C++ object happens here
context->setContextProperty("_currentUser",currentUser);
}
25
Text {
text: _currentUser.name
...
}
When Exporting C++ Object
Accessible from QML:
● Properties
● Signals
● Slots
● Methods marked with Q_INVOKABLE
● Enums registered with Q_ENUM
26
Steps to define a new type in QML:
● In C++: Subclass either QObject or QQuickItem
● In C++: Register the type with the QML environment
● In QML: Import the module containing the new item
● In QML: Use the item like any other standard item
● Non-visual types are QObject subclasses
● Visual types (items) are QQuickItem subclasses
○ QQuickItem is the C++ equivalent of Item
27
● Using Qt Creator
● Model/View
● Localization
● Integrating QML With C++
● Embedded Development
● Best Practices
● Tips and Tricks
● Where To Go Next
● Q&A
Agenda
28
Embedded Development
● Similar to desktop development
● Typically have to use cross-compiler (runs on
desktop, compiles for target)
● Don’t underestimate the effort to get
environment set up
● Also need to get Qt running optimally on your
hardware (can be a significant effort)
● Qt Creator can build for, deploy to, debug, and
profile remote targets
● Qt and third party code licensing is more
complex for embedded.
29
Embedded Development
● Need drivers for display, touchscreen, etc.
● QML requires OpenGL
● Some key decisions:
○ Choice of platform (e.g. embedded Linux, QNX, etc.)
○ Rendering back end (eglfs, xcb, linuxfb, directfb, etc.)
● Ensure adequate RAM, mass storage, CPU
and GPU performance
● Often start by developing UX prototype for
desktop
● Don’t delay moving to the embedded platform!
30
● Using Qt Creator
● Model/View
● Localization
● Integrating QML With C++
● Embedded Development
● Best Practices
● Tips and Tricks
● Where To Go Next
● Q&A
Agenda
31
Best Practices
● Read the Qt documentation, including relevant
examples and demos.
● Have at least a high-level knowledge of all of
Qt's modules.
● Explore third party libraries and components
before reinventing the wheel.
● Take the time to properly set up your qmake
projects and configure Qt Creator.
● Define a test strategy (e.g. write unit tests).
● Set up an automated build system.
32
Best Practices
● Write your code so it is localizable, even if you
have no immediate plans to translate it.
● Always insure your dynamic QObjects have a
parent so they are deleted when the parent is.
● Using Qt’s built-in iterators can help prevent
accessing bad data in container classes and
are compatible with STL algorithms.
● Favor layouts over having your program
position the items with coordinates.
● Understand the difference between QDialog()::
exec() and QWidget()::show().
33
● Using Qt Creator
● Model/View
● Localization
● Integrating QML With C++
● Embedded Development
● Best Practices
● Tips and Tricks
● Where To Go Next
● Q&A
Agenda
34
Introspection Tip
QLabel aLabel;
aLabel.setText("hello world");
aLabel.show();
for (int i=aLabel.metaObject()->propertyOffset();
i < aLabel.metaObject()->propertyCount()
; i++) {
qDebug() << "Property Name :" <<
aLabel.metaObject()->property(i).name();
qDebug() << "Property Value :" <<
aLabel.property(aLabel.metaObject()->property(i).name());
}
35
// You can add properties to your QObject derived classes by using the //
following macro.
Q_PROPERTY(type name READ getFunction [WRITE setFunction])
Tip: Finding The Children
// Signature of Function
QList<T> QObject::findChildren(const QString &name = QString(), Qt::
findChildOptions options = Qt::findChildrenRecursively) const
36
// This example returns all QPushButtons that are children of parentWidget:
QList<QPushButton *> allPButtons = parentWidget.findChildren<QPushButton *>();
// This example returns all QPushButtons that are immediate children of
parentWidget:
QList<QPushButton *> childButtons = parentWidget.findChildren<QPushButton *>
(QString(), Qt::findDirectChildrenOnly);
Exploring Your Enums
enum AppleType {
Big,
Small
};
Q_ENUM(AppleType)
QMetaEnum metaEnum = QMetaEnum::fromType<ModelApple::AppleType>();
qDebug() << metaEnum.valueToKey(ModelApple::Big);
37
● Using Qt Creator
● Model/View
● Localization
● Integrating QML With C++
● Embedded Development
● Best Practices
● Tips and Tricks
● Where To Go Next
● Q&A
Agenda
38
Some suggested next steps for learning Qt:
● Download and install Qt and Qt Creator
● Look at Qt examples and demos; try modifying
them
● Read documentation in Qt Assistant (including
tutorials)
● Take a course
● Create some small applications of your own
● Join the qt-interest mailing list (and possibly others)
● Report bugs
● Test alpha, beta, RC releases
● Review code
● Submit fixes
Where To Go Next
39
● Bug tracker: https://bugreports.qt.io/
● Gerrit code review: https://codereview.qt-project.org/
● Mailing lists: http://lists.qt-project.org/mailman/listinfo
● Wiki: https://wiki.qt.io/
● Blogs: http://blog.qt.io/
● Documentation: http://doc.qt.io/
● Forums: http://forum.qt.io/
● ICS training: http://www.ics.com/learning/training
Where To Go Next
40
● Using Qt Creator
● Model/View
● Localization
● Integrating QML With C++
● Embedded Development
● Best Practices
● Tips and Tricks
● Where To Go Next
● Q&A
Agenda
41
Next Time on Qt for Beginners!
The ICS Qt experts will take your questions on June 23!
Submit questions at http://www.ics.com/ask-your-qt-
questions
or on Twitter with hashtag #QtQuestions
42

Weitere ähnliche Inhalte

Was ist angesagt?

Plugin-based IVI Architectures with Qt
Plugin-based IVI Architectures with Qt Plugin-based IVI Architectures with Qt
Plugin-based IVI Architectures with Qt ICS
 
Basics of Model/View Qt programming
Basics of Model/View Qt programmingBasics of Model/View Qt programming
Basics of Model/View Qt programmingICS
 
Intro to QML / Declarative UI
Intro to QML / Declarative UIIntro to QML / Declarative UI
Intro to QML / Declarative UIOpenBossa
 
Best Practices in Qt Quick/QML - Part 1 of 4
Best Practices in Qt Quick/QML - Part 1 of 4Best Practices in Qt Quick/QML - Part 1 of 4
Best Practices in Qt Quick/QML - Part 1 of 4ICS
 
Qt for Python
Qt for PythonQt for Python
Qt for PythonICS
 
Fun with QML
Fun with QMLFun with QML
Fun with QMLICS
 
Best Practices in Qt Quick/QML - Part I
Best Practices in Qt Quick/QML - Part IBest Practices in Qt Quick/QML - Part I
Best Practices in Qt Quick/QML - Part IICS
 
Migrating from Photon to Qt
Migrating from Photon to QtMigrating from Photon to Qt
Migrating from Photon to QtJanel Heilbrunn
 
Qt Internationalization
Qt InternationalizationQt Internationalization
Qt InternationalizationICS
 
Qt for beginners part 5 ask the experts
Qt for beginners part 5   ask the expertsQt for beginners part 5   ask the experts
Qt for beginners part 5 ask the expertsICS
 
OpenGL Fixed Function to Shaders - Porting a fixed function application to “m...
OpenGL Fixed Function to Shaders - Porting a fixed function application to “m...OpenGL Fixed Function to Shaders - Porting a fixed function application to “m...
OpenGL Fixed Function to Shaders - Porting a fixed function application to “m...ICS
 
Network-Connected Development with ZeroMQ
Network-Connected Development with ZeroMQNetwork-Connected Development with ZeroMQ
Network-Connected Development with ZeroMQICS
 
Serving QML applications over the network
Serving QML applications over the networkServing QML applications over the network
Serving QML applications over the networkJeremy Lainé
 
Meet the Widgets: Another Way to Implement UI
Meet the Widgets: Another Way to Implement UIMeet the Widgets: Another Way to Implement UI
Meet the Widgets: Another Way to Implement UIICS
 
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
 
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
 
An Introduction to the Yocto Embedded Framework 2018
An Introduction to the Yocto Embedded Framework 2018An Introduction to the Yocto Embedded Framework 2018
An Introduction to the Yocto Embedded Framework 2018ICS
 
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
 

Was ist angesagt? (20)

Plugin-based IVI Architectures with Qt
Plugin-based IVI Architectures with Qt Plugin-based IVI Architectures with Qt
Plugin-based IVI Architectures with Qt
 
Basics of Model/View Qt programming
Basics of Model/View Qt programmingBasics of Model/View Qt programming
Basics of Model/View Qt programming
 
Intro to QML / Declarative UI
Intro to QML / Declarative UIIntro to QML / Declarative UI
Intro to QML / Declarative UI
 
QtQuick Day 4
QtQuick Day 4QtQuick Day 4
QtQuick Day 4
 
Best Practices in Qt Quick/QML - Part 1 of 4
Best Practices in Qt Quick/QML - Part 1 of 4Best Practices in Qt Quick/QML - Part 1 of 4
Best Practices in Qt Quick/QML - Part 1 of 4
 
Qt for Python
Qt for PythonQt for Python
Qt for Python
 
Fun with QML
Fun with QMLFun with QML
Fun with QML
 
Best Practices in Qt Quick/QML - Part I
Best Practices in Qt Quick/QML - Part IBest Practices in Qt Quick/QML - Part I
Best Practices in Qt Quick/QML - Part I
 
Migrating from Photon to Qt
Migrating from Photon to QtMigrating from Photon to Qt
Migrating from Photon to Qt
 
Qt Internationalization
Qt InternationalizationQt Internationalization
Qt Internationalization
 
Qt for beginners part 5 ask the experts
Qt for beginners part 5   ask the expertsQt for beginners part 5   ask the experts
Qt for beginners part 5 ask the experts
 
OpenGL Fixed Function to Shaders - Porting a fixed function application to “m...
OpenGL Fixed Function to Shaders - Porting a fixed function application to “m...OpenGL Fixed Function to Shaders - Porting a fixed function application to “m...
OpenGL Fixed Function to Shaders - Porting a fixed function application to “m...
 
Network-Connected Development with ZeroMQ
Network-Connected Development with ZeroMQNetwork-Connected Development with ZeroMQ
Network-Connected Development with ZeroMQ
 
Serving QML applications over the network
Serving QML applications over the networkServing QML applications over the network
Serving QML applications over the network
 
Meet the Widgets: Another Way to Implement UI
Meet the Widgets: Another Way to Implement UIMeet the Widgets: Another Way to Implement UI
Meet the Widgets: Another Way to Implement UI
 
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
 
Qt Programming on TI Processors
Qt Programming on TI ProcessorsQt Programming on TI Processors
Qt Programming on TI Processors
 
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
 
An Introduction to the Yocto Embedded Framework 2018
An Introduction to the Yocto Embedded Framework 2018An Introduction to the Yocto Embedded Framework 2018
An Introduction to the Yocto Embedded Framework 2018
 
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
 

Ähnlich wie Qt for beginners part 4 doing more

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
 
Plasmaquick Workshop - FISL 13
Plasmaquick Workshop - FISL 13Plasmaquick Workshop - FISL 13
Plasmaquick Workshop - FISL 13Daker Fernandes
 
Developing and Benchmarking Qt applications on Hawkboard with Xgxperf
Developing and Benchmarking Qt applications on Hawkboard with XgxperfDeveloping and Benchmarking Qt applications on Hawkboard with Xgxperf
Developing and Benchmarking Qt applications on Hawkboard with XgxperfPrabindh Sundareson
 
Necessitas - Qt on Android - from FSCONS 2011
Necessitas - Qt on Android - from FSCONS 2011Necessitas - Qt on Android - from FSCONS 2011
Necessitas - Qt on Android - from FSCONS 2011Johan Thelin
 
Migrating from Photon to Qt
Migrating from Photon to QtMigrating from Photon to Qt
Migrating from Photon to QtICS
 
Network programming with Qt (C++)
Network programming with Qt (C++)Network programming with Qt (C++)
Network programming with Qt (C++)Manohar Kuse
 
Untitled presentation(4)
Untitled presentation(4)Untitled presentation(4)
Untitled presentation(4)chan20kaur
 
Robust C++ Task Systems Through Compile-time Checks
Robust C++ Task Systems Through Compile-time ChecksRobust C++ Task Systems Through Compile-time Checks
Robust C++ Task Systems Through Compile-time ChecksStoyan Nikolov
 
下午3 intel fenghaitao_mee_go api and application development
下午3 intel fenghaitao_mee_go api and application development下午3 intel fenghaitao_mee_go api and application development
下午3 intel fenghaitao_mee_go api and application developmentcsdnmobile
 
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
 
Free GitOps Workshop (with Intro to Kubernetes & GitOps)
Free GitOps Workshop (with Intro to Kubernetes & GitOps)Free GitOps Workshop (with Intro to Kubernetes & GitOps)
Free GitOps Workshop (with Intro to Kubernetes & GitOps)Weaveworks
 
IIT-RTC 2017 Qt WebRTC Tutorial (Qt Janus Client)
IIT-RTC 2017 Qt WebRTC Tutorial (Qt Janus Client)IIT-RTC 2017 Qt WebRTC Tutorial (Qt Janus Client)
IIT-RTC 2017 Qt WebRTC Tutorial (Qt Janus Client)Alexandre Gouaillard
 
PGConf APAC 2018 - Patroni: Kubernetes-native PostgreSQL companion
PGConf APAC 2018 - Patroni: Kubernetes-native PostgreSQL companionPGConf APAC 2018 - Patroni: Kubernetes-native PostgreSQL companion
PGConf APAC 2018 - Patroni: Kubernetes-native PostgreSQL companionPGConf APAC
 

Ähnlich wie Qt for beginners part 4 doing more (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
 
Qt 5 - C++ and Widgets
Qt 5 - C++ and WidgetsQt 5 - C++ and Widgets
Qt 5 - C++ and Widgets
 
Qt
QtQt
Qt
 
Plasmaquick Workshop - FISL 13
Plasmaquick Workshop - FISL 13Plasmaquick Workshop - FISL 13
Plasmaquick Workshop - FISL 13
 
Developing and Benchmarking Qt applications on Hawkboard with Xgxperf
Developing and Benchmarking Qt applications on Hawkboard with XgxperfDeveloping and Benchmarking Qt applications on Hawkboard with Xgxperf
Developing and Benchmarking Qt applications on Hawkboard with Xgxperf
 
Necessitas - Qt on Android - from FSCONS 2011
Necessitas - Qt on Android - from FSCONS 2011Necessitas - Qt on Android - from FSCONS 2011
Necessitas - Qt on Android - from FSCONS 2011
 
Migrating from Photon to Qt
Migrating from Photon to QtMigrating from Photon to Qt
Migrating from Photon to Qt
 
Network programming with Qt (C++)
Network programming with Qt (C++)Network programming with Qt (C++)
Network programming with Qt (C++)
 
Untitled presentation(4)
Untitled presentation(4)Untitled presentation(4)
Untitled presentation(4)
 
Qt coin3d soqt
Qt coin3d soqtQt coin3d soqt
Qt coin3d soqt
 
Robust C++ Task Systems Through Compile-time Checks
Robust C++ Task Systems Through Compile-time ChecksRobust C++ Task Systems Through Compile-time Checks
Robust C++ Task Systems Through Compile-time Checks
 
下午3 intel fenghaitao_mee_go api and application development
下午3 intel fenghaitao_mee_go api and application development下午3 intel fenghaitao_mee_go api and application development
下午3 intel fenghaitao_mee_go api and application development
 
Qt for beginners
Qt for beginnersQt for beginners
Qt for beginners
 
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
 
PyQt.pptx
PyQt.pptxPyQt.pptx
PyQt.pptx
 
Free GitOps Workshop (with Intro to Kubernetes & GitOps)
Free GitOps Workshop (with Intro to Kubernetes & GitOps)Free GitOps Workshop (with Intro to Kubernetes & GitOps)
Free GitOps Workshop (with Intro to Kubernetes & GitOps)
 
IIT-RTC 2017 Qt WebRTC Tutorial (Qt Janus Client)
IIT-RTC 2017 Qt WebRTC Tutorial (Qt Janus Client)IIT-RTC 2017 Qt WebRTC Tutorial (Qt Janus Client)
IIT-RTC 2017 Qt WebRTC Tutorial (Qt Janus Client)
 
PGConf APAC 2018 - Patroni: Kubernetes-native PostgreSQL companion
PGConf APAC 2018 - Patroni: Kubernetes-native PostgreSQL companionPGConf APAC 2018 - Patroni: Kubernetes-native PostgreSQL companion
PGConf APAC 2018 - Patroni: Kubernetes-native PostgreSQL companion
 
Cross Platform Qt
Cross Platform QtCross Platform Qt
Cross Platform Qt
 

Mehr von 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
 

Mehr von 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
 

Kürzlich hochgeladen

Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CVKhem
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?Igalia
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)wesley chun
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEarley Information Science
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 

Kürzlich hochgeladen (20)

Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 

Qt for beginners part 4 doing more

  • 1. Qt For Beginners - Part 4 Doing More Christopher Probst, Qt Consultant Integrated Computer Solutions Visit us at http://www.ics.com Video Available at: http://bit.ly/qt-beginners-part-4-more Copyright 2016, Integrated Computers Solutions, Inc. This work may not be reproduced in whole or in part without the express written consent of Integrated Computer Solutions, Inc. 1
  • 2. ● Using Qt Creator ● Model/View ● Localization ● Integrating QML With C++ ● Embedded Development ● Best Practices ● Tips and Tricks ● Where To Go Next ● Q&A Agenda 2
  • 3. ● Using Qt Creator ● Model/View ● Localization ● Integrating QML With C++ ● Embedded Development ● Best Practices ● Tips and Tricks ● Where To Go Next ● Q&A Agenda 3
  • 4. Qt Creator Kit 4 A kit consists of: ● Qt version (path to qmake) ● Debugger ● Compiler ● Target platform ● Build configuration (Qt mkspec) ● Other environment specs
  • 5. Kit Selection ● A Qt Creator user can navigate across multiple kits ● Facilitates the management of multiple Qt versions, compilers, debuggers ● Ideal cross compilation and deployment to other devices 5
  • 6. Project Configuration Tabs for each project (kit), build and run settings: 6
  • 7. Ctrl + [1-7]: Switch between various screens ● Welcome Screen ● Edit Mode ● Debug ● etc Alt + [0-4]: Toggle which output panes are visible ● Sidebar ● Build Issues ● Search Results ● Application Output ● Compile Output F2: Follow the highlighted symbol Ctrl + i: Auto-indent selected code Ctrl + /: Comment selected code Ctrl + tab: Navigate through the files Shortcuts 7
  • 8. Shortcuts Specifying your own shortcut keys! 8
  • 9. Fake Vim If you miss Vim! 9
  • 10. ● Using Qt Creator ● Model/View ● Localization ● Integrating QML With C++ ● Embedded Development ● Best Practices ● Tips and Tricks ● Where To Go Next ● Q&A Agenda 10
  • 11. What is Model/View? ● A design pattern that aims to separate implementation of the visual interface from the business logic that drives it. ● This design pattern is common throughout Qt. ○ Integration of UI files (Qt Designer) ○ Loading of QML files ○ Item-View Classes 11
  • 12. Item-View and Model/View Classes ● To display large sets of indexed data, Qt provides a Model/View architecture: Model/View/Delegate ● The views are provided by convenience classes 12 QTableView QTreeView
  • 13. Model Classes ● The preceding views are given a model ● Qt provides base model classes that the programmer generally subclasses. ○ QAbstractItemModel ○ QAbstractListModel ○ QAbstractTableModel 13 ui->DownloadTable->setModel(downloadModel); void QAbstractItemView::setModel(QAbstractItemModel * model)
  • 14. Model/View Example We want to create an iTunes/Napster-like download tool that concurrently downloads multiple files: 14 Download Manager UI Example
  • 15. Model Class Example class DownloadsModel : public QAbstractTableModel { Q_OBJECT public: DownloadsModel(QObject *parent = 0); // QAbstractItemModel interface int rowCount(const QModelIndex &parent = QModelIndex()) const; int columnCount(const QModelIndex &parent = QModelIndex()) const; QVariant data(const QModelIndex &index, int role) const; QVariant headerData(int section, Qt::Orientation orientation, int role) const; ... private: // Our model “knows” how to access the data for the view QList<Downloads*> DownLoadList; }; 15
  • 16. Model Talking to the View QVariant DownloadsModel::data(const QModelIndex &index, int role) const { if (role == Qt::DisplayRole) { // Data for first column if (index.column() == 0) { // Data for view QUrl url = DownLoadList.at(index.row())->url(); return url; } // Data for second column else if (index.column() == 1) { // Data for view int progressPercentage = (DownLoadList.at(index.row())->progress() * 100 / DownLoadList.at(index.row())->total()); return progressPercentage; } } return QVariant(); } 16 Through the QAbstractItemModel::data(..) function, the model, given a row and a column, returns the appropriate data
  • 17. The Delegate ● If the view provided by Qt does not display the data visually as desired, we implement a delegate ● The delegate class is used to specify how data is rendered by the view ● Instead of displaying a number, we want to display a progress bar 17
  • 18. Delegate Implementation void ProgressBarDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const { if (index.column() == 1) { int progressPercentage = index.model()->data(index, Qt::DisplayRole).toInt(); QStyleOptionProgressBar progressBarOption; progressBarOption.rect = QRect(option.rect.x() + 5, option.rect.y() + 5, option.rect.width() - 10, option.rect.height() - 10); progressBarOption.minimum = 0; progressBarOption.maximum = 100; progressBarOption.progress = progressPercentage; progressBarOption.text= QString::number(progressPercentage) + "%"; progressBarOption.textAlignment = Qt::AlignCenter; progressBarOption.textVisible = true; if (option.state & QStyle::State_Selected) painter->fillRect(option.rect, option.palette.alternateBase()); QApplication::style()->drawControl( QStyle::CE_ProgressBar, &progressBarOption, painter); } else { QStyledItemDelegate::paint(painter, option, index); } } 18 ProgressBarDelegate* delegate = new ProgressBarDelegate(this); ui->DownloadTable->setItemDelegateForColumn( 1, delegate);
  • 19. ● Using Qt Creator ● Model/View ● Localization ● Integrating QML With C++ ● Embedded Development ● Best Practices ● Tips and Tricks ● Where To Go Next ● Q&A Agenda 19
  • 20. Localization 20 Code label->setText(tr("Greeting")); Tool lupdate Project File (app.pro) TRANSLATIONS += app_de.ts CODECFORTR = UTF-8 Tool Qt Linguist TS File app_de.ts Tool lrelease QM File app_de.qm Code QTranslator translator; translator. load("app_de"); app.installTranslator (&translator); provide translation 2 load translation 4 extracts translations updates ts file compile translation 3 1
  • 21. Localization In C++: QString s = tr("Text String"); setWindowTitle(tr("File: %1 Line: %2").arg(f).arg(l)); //: This comment is seen by translation staff label->setText(tr("Name: %1 Date: %2").arg(name, d.toString())); 21 In QML: Button { id: button1 text: qsTr("Press Me") }
  • 22. ● Using Qt Creator ● Model/View ● Localization ● Integrating QML With C++ ● Embedded Development ● Best Practices ● Tips and Tricks ● Where To Go Next ● Q&A Agenda 22
  • 23. Loading the QML File #include <QGuiApplication> #include <QQmlApplicationEngine> int main(int argc, char *argv[]) { QGuiApplication app(argc, argv); QQmlApplicationEngine engine; engine.load(QUrl("qrc:/main.qml")); return app.exec(); } 23 QT += qml quick CONFIG += c++11 SOURCES += main.cpp RESOURCES += qml.qrc In the .pro file... In the main.cpp file...
  • 24. Exporting C++ Objects to QML class Message : public QObject { Q_OBJECT Q_PROPERTY(QString author READ author WRITE setAuthor NOTIFY authorChanged) Q_PROPERTY(QDateTime creationDate READ creationDate WRITE setCreationDate NOTIFY creationDateChanged) public: // ... }; 24 qmlRegisterType<Message>("com.mycompany.messaging", 1, 0, "Message"); import com.mycompany.messaging 1.0 Message { author: "Amelie" creationDate: new Date() } Exported file In header file Registering the class in the code before the QML is loaded Using class in QML file
  • 25. Alternate Way of Exporting C++ Object #include "user.h" #include <QApplication> void main(int argc, char* argv[]) { QApplication app(argc, argv); qmlRegisterType<User>("com.mycompany.qmlcomponents", 1, 0, "User"); User *currentUser = new User("Alice", 29); QQuickView *view = new QQuickView; QQmlContext *context = view->engine()->rootContext(); // Exporting of C++ object happens here context->setContextProperty("_currentUser",currentUser); } 25 Text { text: _currentUser.name ... }
  • 26. When Exporting C++ Object Accessible from QML: ● Properties ● Signals ● Slots ● Methods marked with Q_INVOKABLE ● Enums registered with Q_ENUM 26
  • 27. Steps to define a new type in QML: ● In C++: Subclass either QObject or QQuickItem ● In C++: Register the type with the QML environment ● In QML: Import the module containing the new item ● In QML: Use the item like any other standard item ● Non-visual types are QObject subclasses ● Visual types (items) are QQuickItem subclasses ○ QQuickItem is the C++ equivalent of Item 27
  • 28. ● Using Qt Creator ● Model/View ● Localization ● Integrating QML With C++ ● Embedded Development ● Best Practices ● Tips and Tricks ● Where To Go Next ● Q&A Agenda 28
  • 29. Embedded Development ● Similar to desktop development ● Typically have to use cross-compiler (runs on desktop, compiles for target) ● Don’t underestimate the effort to get environment set up ● Also need to get Qt running optimally on your hardware (can be a significant effort) ● Qt Creator can build for, deploy to, debug, and profile remote targets ● Qt and third party code licensing is more complex for embedded. 29
  • 30. Embedded Development ● Need drivers for display, touchscreen, etc. ● QML requires OpenGL ● Some key decisions: ○ Choice of platform (e.g. embedded Linux, QNX, etc.) ○ Rendering back end (eglfs, xcb, linuxfb, directfb, etc.) ● Ensure adequate RAM, mass storage, CPU and GPU performance ● Often start by developing UX prototype for desktop ● Don’t delay moving to the embedded platform! 30
  • 31. ● Using Qt Creator ● Model/View ● Localization ● Integrating QML With C++ ● Embedded Development ● Best Practices ● Tips and Tricks ● Where To Go Next ● Q&A Agenda 31
  • 32. Best Practices ● Read the Qt documentation, including relevant examples and demos. ● Have at least a high-level knowledge of all of Qt's modules. ● Explore third party libraries and components before reinventing the wheel. ● Take the time to properly set up your qmake projects and configure Qt Creator. ● Define a test strategy (e.g. write unit tests). ● Set up an automated build system. 32
  • 33. Best Practices ● Write your code so it is localizable, even if you have no immediate plans to translate it. ● Always insure your dynamic QObjects have a parent so they are deleted when the parent is. ● Using Qt’s built-in iterators can help prevent accessing bad data in container classes and are compatible with STL algorithms. ● Favor layouts over having your program position the items with coordinates. ● Understand the difference between QDialog():: exec() and QWidget()::show(). 33
  • 34. ● Using Qt Creator ● Model/View ● Localization ● Integrating QML With C++ ● Embedded Development ● Best Practices ● Tips and Tricks ● Where To Go Next ● Q&A Agenda 34
  • 35. Introspection Tip QLabel aLabel; aLabel.setText("hello world"); aLabel.show(); for (int i=aLabel.metaObject()->propertyOffset(); i < aLabel.metaObject()->propertyCount() ; i++) { qDebug() << "Property Name :" << aLabel.metaObject()->property(i).name(); qDebug() << "Property Value :" << aLabel.property(aLabel.metaObject()->property(i).name()); } 35 // You can add properties to your QObject derived classes by using the // following macro. Q_PROPERTY(type name READ getFunction [WRITE setFunction])
  • 36. Tip: Finding The Children // Signature of Function QList<T> QObject::findChildren(const QString &name = QString(), Qt:: findChildOptions options = Qt::findChildrenRecursively) const 36 // This example returns all QPushButtons that are children of parentWidget: QList<QPushButton *> allPButtons = parentWidget.findChildren<QPushButton *>(); // This example returns all QPushButtons that are immediate children of parentWidget: QList<QPushButton *> childButtons = parentWidget.findChildren<QPushButton *> (QString(), Qt::findDirectChildrenOnly);
  • 37. Exploring Your Enums enum AppleType { Big, Small }; Q_ENUM(AppleType) QMetaEnum metaEnum = QMetaEnum::fromType<ModelApple::AppleType>(); qDebug() << metaEnum.valueToKey(ModelApple::Big); 37
  • 38. ● Using Qt Creator ● Model/View ● Localization ● Integrating QML With C++ ● Embedded Development ● Best Practices ● Tips and Tricks ● Where To Go Next ● Q&A Agenda 38
  • 39. Some suggested next steps for learning Qt: ● Download and install Qt and Qt Creator ● Look at Qt examples and demos; try modifying them ● Read documentation in Qt Assistant (including tutorials) ● Take a course ● Create some small applications of your own ● Join the qt-interest mailing list (and possibly others) ● Report bugs ● Test alpha, beta, RC releases ● Review code ● Submit fixes Where To Go Next 39
  • 40. ● Bug tracker: https://bugreports.qt.io/ ● Gerrit code review: https://codereview.qt-project.org/ ● Mailing lists: http://lists.qt-project.org/mailman/listinfo ● Wiki: https://wiki.qt.io/ ● Blogs: http://blog.qt.io/ ● Documentation: http://doc.qt.io/ ● Forums: http://forum.qt.io/ ● ICS training: http://www.ics.com/learning/training Where To Go Next 40
  • 41. ● Using Qt Creator ● Model/View ● Localization ● Integrating QML With C++ ● Embedded Development ● Best Practices ● Tips and Tricks ● Where To Go Next ● Q&A Agenda 41
  • 42. Next Time on Qt for Beginners! The ICS Qt experts will take your questions on June 23! Submit questions at http://www.ics.com/ask-your-qt- questions or on Twitter with hashtag #QtQuestions 42