Meet Qt. Justin Noel Senior Consulting Engineer ICS, Inc.

Size: px
Start display at page:

Download "Meet Qt. Justin Noel Senior Consulting Engineer ICS, Inc."

Transcription

1 Meet Qt Justin Noel Senior Consulting Engineer ICS, Inc.

2 Agenda Who is ICS? The Case For Qt Qt Tips and Tricks Effective QML

3 Who is ICS?

4 Delivering World-Class, Touchscreen Applications Embedded Mobile Tablets Kiosks Desktops To maintain client confidentiality, some examples are illustrative not actual.

5 Product Focused Services Full project implementation From UX design to QA Software development Multi-team projects to staff augmentation UX development Technology transfer Agile Coaching, Mentoring, Training, etc.

6 About ICS * Founded 1987 Corvallis Sunnyvale Los Angeles Ottawa Boston Atlanta Warsaw Naples Moscow Kiev Worldwide Offices * Qualifies as Small Business

7 More Info

8 The Case For Qt

9 Agenda What exactly is Qt? Desktop Applications Mobile Devices Embedded Devices QtQuick Model/View Design

10 What is Qt? Application Development Framework More than just a GUI Toolkit Come for the UI. Stay for everything else! Kitchen Sink C++ Library Threads, SQL, XML, Non-Blocking Sockets Over 600 Classes

11 Qt is Cross-Platform Write Once. Compile Anywhere. Windows / WinCE / WinRT Linux QNX, VxWorks Android, ios, BlackBerry

12 Qt Makes Life Easy

13 Qt Makes Life Easy Qt is designed around ease of use Many conveniences for common use cases Roughly zero boilerplate code API is easy to learn and is consistent Qt isms are easier than boost isms + libxml isms

14 Qt Modules and Toolss

15 HelloWorld in Qt #include <QApplication> #include <QLabel> int main(int argc, char *argc[]) { QApplication app(argc, argv); QLabel label = new QLabel( Hello World ); label.show(); app.exec(); }

16 Signals and Slots Inter-object communication Callbacks? Listeners? Events? All flawed in their own way Signals and Slots is Qt s answer Contractless Observer Pattern

17 Signals and Slots void Slider::mousePressEvent(... ) {... emit valuechanged( newvalue ); } void LCDNumber::setNumber(int num) { my_value = num; } Signal Emitted Signal and Slot Connection Slot Implemented connect( slider, SIGNAL( valuechanged( int ) ), lcdnumber, SLOT( display ( int ) ) )

18 Signals and Slots Qt does all the heavy lifting Connection management Delete a sender or receiver? No Problem! Type checking, marshalling, etc. Signals and slots work across threads!

19 Qt is Really Smart Qt implements introspection Much like Java Query for method names, signals, enums, etc. Qt provides moc (Meta-Object Compiler) Reads your headers. Provides introspection sources This is how signals and slots work!

20 Qt is Worldly UNICODE strings from the ground up Built in utilities for internationalization Languages, plurals, dates, numbers Ships with translation tools For use by non-developers

21 Desktop Applications

22 Qt Has History Version 1.0 released in 1995 Happy 20 th Birthday! UNIX and Windows cross-platform Huge list of supported OSs and compilers Qt was 64 bit clean on the DEC Alpha Mac suport was added in 1999

23 Qt Looks Right

24 Qt is Convenient QMainWindow MenuBar, ToolBars, StatusBar Dock Areas Work on what makes your app special Not on coding standard paradigms

25 QMainWindow

26 Mobile Applications

27 Qt is Cross-Platform Android ios Windows Phone 8 / WinRT BlackBerry 4.8 ships on BB10 5.x coming soon

28 Share Backend Code Write C++ backend code once Reuse on all major mobile platforms That can run C++ Threads, Networking, SQL, XML All from one API

29 Even Write the UI QtGui runs on all the above platforms QtQuick too! Each mobile platform has it s own nav Either UI must be severely tweaked for each; or Treat UI as a light wrapper layer Write a new skin for each» More on this in Embedded Devices

30 Even Write the UI QtGui runs on all the above platforms QtQuick too! Each mobile platform has it s own nav Either UI must be severely tweaked for each; or Treat UI as a light wrapper layer Write a new skin for each» More on this in Embedded Devices

31 Embedded Devices

32 Did I Mention Cross-Platform? Linux OpenGL ES, X11, Wayland QNX / VxWorks OpenGL ES WinCE / WEC7 GDI / OpenGL ES

33 Qt Has Qt Quick Build dynamic design driven UIs Animations, Transitions, State Machines Built into a declarative user interface language Clean architecture Enforced Model / View Design

34 Design Driven UI

35 Layered Design (Coffee Maker) UI User chooses Size, Bold, Ice, etc. Core BrewCoffeeCommand Devices Grinder, Pumps, Heat Element Hardware GPIO, SPI, I/O

36 Model / View Design Properties C++ Backend (Model) Signals QML Items (View) Slots

37 Model / View Design C++ code knows nothing about the UI QML Items connect or bind to C++ Objects C++ does not know about UI at all Good Design is Enforced Avoids accidental storage of data inside UI C++ is more portable to other UI frameworks

38 Model / View Design Props C++ Backend Might Use Qt Might Not QML Adapters Signals Slots QML Items

39 QML Adapter Classes Responsible for Qt-ifying application data Wrap state and data objects in QObject Properties, Signals, Slots Wrap list-like objects in QAbstractItemModel Required if your backend does not use Qt

40 Testability Test C++ code separately from UI Unit test and poke it s outer interfaces Verify and certify it works as designed Test UI without the backend Inject mock backend objects Mocks can be written in QML

41 What is QtQuick? Declarative User Interface Language a.k.a QML Execution runtime for QML Custom V4 JavaScript Engine Developer Tools Profiler, Debugger, etc.

42 QML Hello World import QtQuick 1.0 Rectangle { height: 200; width: 200 } Text { } Image { } x: 100; y: 100; width: 200 color: white x: 20; y: 20 width 150; height: 120; source: rocket.jpg

43 Connecting QtQuick to C++ QObject Wrap C++ objects in QObject Introspection! Signals, Slots and Properties Properties Combination of Get / Set / Signal

44 Qt Tips and Tricks

45 Today's Agenda MetaObject Tips Qt Properties, Dynamic Function Calling QVariant and Implicit Sharing Tips Using Your Data Types Model View Tips QAbstractItemModel As Interface To Data Performance Tips Looping, QPixmap/QImage, QNetworkAccessManager

46 Today's Agenda Threading Tips QtConcurrent, Signals/Slots, Event Loops Miscellaneous Tips ComboBox itemdata(), i81n, Designer, casts Testing Tips QTest, Q_ASSERT, Signals/Slots

47 Meta Object Tips

48 Qt s Property System Use Q_PROPERTY() macro in your widget Declares a property with meta-object system Wraps set/get methods and signal Q _PROPERTY ( Type Name READ getfunction [WRITE setfunction ] [RESET resetfunction ] [DESIGNABLE bool ] [SCRIPTABLE bool ] [STORED bool ] [NOTIFY signal] [USER bool])

49 Q_PROPERTY Rules Types must be QVariant compatible Custom types need Q_DECLARE_METATYPE and qregistermetatype<>() To use enums as a property type use Q_ENUMS macro If your enum can be OR d use Q_FLAGS myflag = MyClass::Read MyClass::Write;

50 Q_PROPERTY Example class MyTitleWidget : public QWidget { Q_OBJECT Q_PROPERTY( QString title READ title WRITE settitle RESET cleartitle ) public: QString title(); public slots: void settitle(qstring); void cleartitle(); };

51 Q_ENUM Example class MyClass : public... { Q_OBJECT Q_ENUM( Priority ) Q_PROPERTY( Priority priority READ priority WRITE setpriority ) public: enum Priority { HIGH, MED, LOW }; Priority priority(); public slots: void setpriority(priority); };

52 Q_PROPERTY Advantages Properties can be saved/loaded in Designer Properties are exported to variables in QtScript Enables the generic setproperty(qvariant) and property() generic functions

53 Dynamic Function Calling QMetaObject::invokeMethod( ) Can invoke any slot Sync or Async With parameters and return type No access to return type for async invocations Useful for delayed initialization Like QTimer::singleShot(), but with arguments! Useful for IPC mechanisms

54 QMetaObject::invokeMethod() bool QMetaObject::invokeMethod( QObject* obj, const char* member, Qt::ConnectionType type, QGenericReturnArgument ret, QGenericArgument val0,... QGenericArgument val9 );

55 invokemethod Helper Macros QGenericReturnArgument and QGenericArgument are internal helper classes for argument marshalling Do no use these classes directly; use the convenience macros instead Create a QGenericArgument Q_ARG( Type, const Type & value ) Create a QGenericReturnArgument Q_RETURN_ARG( Type, Type& value )

56 invokemethod Connection Type Invoke method immediately (synchronous) QMetaObject::invokeMethod(obj, "dostuff", Qt::DirectConnection); Place in event queue and invoke method when event is processed (asynchronous) QMetaObject::invokeMethod(obj, "dostuff", Qt::QueuedConnection);

57 invokemethod Connection Type Invoke method immediately (synchronous) QMetaObject::invokeMethod(obj, "dostuff", Qt::DirectConnection); Place in event queue and invoke method when event is processed (asynchronous) QMetaObject::invokeMethod(obj, "dostuff", Qt::QueuedConnection);

58 When to use invokemethod Use when calling methods by name Method name does not have to be known at compile time Think IPC Use for delayed invocation Method calls will be posted to the event loop potentially the event loop of other threads This is how cross thread signals/slots work

59 QVariant and Implicit Sharing Tips

60 QVariant Template Based Meta Type Can contain C++ types Can contain most Qt Types Can contain custom types If properly registered QVariants are used all over Qt and you can use them too Model-view, properties, cross-thread signals and slots

61 Registering Types Use Q_DECLARE_METATYPE(Type) in header Call qregistermetatype<>(type) at least once in your code

62 class Car { public: Custom Types in QVariant Car(const QString& make, const QString model); QString make() const; QString model() const; private: QString _make; QSrting _model; }; Q_DECLARE_METATYPE(Car); //Anywhere in code before using Car as QVariant in //Properties or Cross-Thread Signals and Slots qregistermetatype<car>( Car )

63 Converting Types You must use the template methods for custom types MyType mytype; QVariant var = QVariant::fromValue(myType); if( var.canconvert<mytype>() ) { MyType type = qvariant_cast<mytype>(var) } QVariant::Type QVariant::type() not useful Only works with C++ and Qt Types

64 Extending QVariant Comparison Doesn t Work for Custom Types Compares object addresses Serialization Can Work Implement Operators QDataStream &operator<<(qdatastream &out, const MyClass &myobj); QDataStream &operator>>(qdatastream &in, MyClass &myobj); Register with QMetaType System qregistermetatypestreamoperators<myclass>( MyClass );

65 Implicitly Shared Classes Most of Qt s Data Classes are Implicitly Shared Copies of classes point to the same internal data Very fast copies. Saves memory Reference counted Data is actually copied on modification Copy-On-Write Semantics QString, QPixmap, QImage, QByteArray, etc You can roll your own Implicitly Shared Classes Using the same classes Qt Engineers use!

66 Custom Implicitly Shared Data Inherit from QSharedData Provides required ref() and deref() impls These are atomic thread-safe impls Create a flyweight object with SharedDataPointer<> as a private member Hides sharing implementation from client code

67 Custom Implicitly Shared Data class EmployeeData : public QSharedData { public: EmployeeData() : id(-1) { name.clear(); } EmployeeData(const EmployeeData &other) : QSharedData(other), id(other.id),name(other.name){} ~EmployeeData() { } }; int id; QString name;

68 Custom Implicitly Shared Data class Employee { public: Employee() { d = new EmployeeData; } Employee(int id, QString name) { } d = new EmployeeData; setid(id); setname(name); Employee(const Employee &other) private: }; : d (other.d) {} QSharedDataPointer<EmployeeData> d;

69 Model View Tips

70 Model View Tips Avoid using all-in-one Model/View Widgets QListWidget, QTableWidget, QTreeWidget Needs to copy data! Syncing issue WILL arise Only really useful for simple lists, etc Avoid using QStandardItem Models Same reasons as above.

71 Model View Tips Use QAbstractItemModel (QAIM) as an Interface Wrap your data with QAIM for use with Qt s Model-View Classes Actual Data Storage Class QAIM Impl Qt View

72 QModelIndex Representation of a cell Row, Column, Parent QAIM::index(int row, int col, QModelIndex parent) Used thought the QAIM API Internal implementation is Row, Column, QAIM*, Identifier (void* or int) QAIM::createIndex(int row, int col, void* ptr) Very Small. Very Fast. Transient objects DO NOT STORE! Could be instantly invalidated by inserts/removes

73 QPersistentModelIndex Storable QModelIndex Implicit conversion to/from QModelIndex Model Index that is maintained by the Model Row incremented on another row inserted Row decremented on another row removed Index set to QModelIndex() when row is removed Watch out for performance issues Updating these indexes does take time

74 QAIM API Read Only Tables (Use QAbstractTableModel) rowcount(qmodelindex parent=qmodelindex()) columncount(qmodelindex parent=qmodelindex()) data(qmodelindex idx, int role) Different roles for display, editing, pixmap, etc. It s like a 3 rd Dimension. Cells have role depth. Editable Tables (Use QAbstractTableModel) setdata(qmodelindex idx, QVariant value, int role) insertrows(int row, int count, QModelIndex parent) removerows(int row, int count, QModelIndex parent)

75 QAIM API Trees (Use QAbstractItemModel) parent(qmodelindex idx) index(int row, int column, QModelIndex parent) Implementations of the above can be a little mind bending But well worth the effort

76 Model View Example Example of AQIM as a wrapper. To Qt Application Widget Hierarchy! It s a doubly linked tree! parent() and children() Extremely short code wrapper code. Check out the supplied ObjectBrowser Example!

77 QStyle For Custom Widgets Tips Drawing of Qt Widgets is completely delegated to QStyle. Based on QPainter and not QWidget. Super easy to draw fake widgets Works for great for Item Delegates (think ProgressBars) Use Qt Style to draw parts of your own widgets Implement a SliderSpinBox Implement a Tree Combo Box

78 Painting with QStyle void QicsTreeComboBox::paintEvent(QPaintEvent*) { //Data struct with public members like font, palette QStyleOptionComboBox opt = getstyleoption(); QStylePainter painter(this); painter.setpen(palette().color(qpalette::text)); // draw the combobox frame, focusrect and selected etc. painter.drawcomplexcontrol(qstyle::cc_combobox, opt); } // draw the icon and text painter.drawcontrol(qstyle::ce_comboboxlabel, opt);

79 User Interaction with QStyle void QicsTreeComboBox::mousePressEvent(QMouseEvent* e) { QStyleOptionComboBox opt = getstyleoption(); QStyle::SubControl sc = style()->hittestcomplexcontrol( QStyle::CC_ComboBox, &opt, e->pos(),this); // Was mouse over arrow? if (sc == QStyle::SC_ComboBoxArrow) { if(true == m_viewisopen) hideview(); else showview(); } }

80 Performance Tips

81 Looping Performance Tips Use Iterators! Maps, Hashes, Linked List Iterators are much faster than [i] index loopups. Code is more complex, but worth it. Most data classes in Qt are Implicitly Shared Don t be afraid to copy de-referenced iterator values Const Reference is still better.

82 STL Iterators Compatible with STL Algorithms Const and Non-const Versions Always use const version when appropriate Forwards QList<int>::iterator i; for (i = list.begin(); i!= list.end(); ++i) *i += 2; Reverse QList<QString>::iterator i = list.end(); while (i!= list.begin()) { --i;

83 Reverse (and Mutable) QMutableListIterator<int> i(list); i.toback(); while (i.hasprevious()) { if (i.previous() % 2!= 0) Java-like Iterators Iterators with a Java Style API Roughly Symmetrical Forward and Reverse APIs Mutable Iterator Classes allow list modification Forwards QListIterator<QString> i(list); while (i.hasnext()) qdebug() << i.next()

84 Looping Performance Tips Use const references for foreach() Yes, Qt has it s own foreach macro. Use it! Avoids typos/fence posting when iterating a whole container Using a const ref variable avoids a copy QList<BigData> list; //Lots of code foreach(const BigData& data, list) { } dosomething(data);

85 QImage vs. QPixmap QImage Platform independent array bitmap Lives in Application Memory Space Easy to manipulate pixels Query/set colors Needs to be copied to graphics memory to draw QPixmap Native representation of a bitmap (YUV, etc) Lives in System (XServer) or even Graphics Memory No ability to set individual pixels Very fast to draw. Bitmap is closer to hardware.

86 QNetworkAccessManager Cache QNetworkAccessManager (QNAM) is awesome Multiple Protocols (HTTP/FTP/HTTPS) SSL Integrated Provides Caching of Data Can be persistent across runtimes LightMaps from Qt Labs is a perfect example

87 QNetworkAccessManager Cache LightMaps Example Uses OpenStreetMap Tiles QNAM automatically caches tiles as they are loaded Makes panning much faster And code very clean

88 QNetworkAccessManager Cache In Constructor m_manager = new QNetworkAccessManager(this); QNetworkDiskCache *cache = new QNetworkDiskCache; cache->setcachedirectory(cachepath); m_manager->setcache(cache); connect(m_manager, SIGNAL(finished(QNetworkReply*)), this, SLOT(handleNetworkData(QNetworkReply*)));

89 QNetworkAccessManager Cache In download() (Simplified to fit) QString path = " m_url = QUrl(path.arg(zoom).arg(x).arg(y)); QNetworkRequest request; request.seturl(m_url); request.setattribute(qnetworkrequest::user, grab); m_pendingreplies << m_manager->get(request);

90 Miscellaneous Tips

91 Safer Casts with qobject_cast qobject_cast<>() is a library safe dynamic cast Behaves much like dynamic_cast Returns NULL pointer on error Uses Qt Meta-Object System (Introspection) moc records all signals, slots, properties Also inheritance hierarchy and string class names Naive impl could use the string class name and a static cast Some older compilers did this for dynamic_cast! Actual impl compares static QMetaObject*s Fast!

92 Finding Children T findchildren<t>(qstring name=qstring()) Returns descendants from any level of parenting tree Built-in qobject_cast<>() QList<MyWidget*> children = findchildren<mywidget*>(); //Children has all instance of MyWidget in dialog. QList<MyWidget*> children = findchildren<mywidget*>( Hi ); //Children has one instance of MyWidget with //objectname() == Hi

93 Use QComboBox itemdata() Use User Data when inserting items additem(const QString & text, const QVariant userdata)) QVariant is a wrapper class for many Qt Data Classes Can be extended to support custom classes Easy way to store mappings User Selectable String/Icon to Enum/Color/Font

94 Use QComboBox itemdata() Font Combo Box Example: MyDialog::MyDialog() { QStringList fonts = QFontDatabase::families(); foreach(qsyring family, fontlist) m_combo->additem(family, QFont(family)); } MyDialog::indexChanged(int index) { } setfont(m_combo->itemdata(i).tofont());

95 i18n Tips Wrap all User Visible String in tr() lupdate, lrelease and linguist take care of the rest Use static Qbject::translate() outside of QObject scope Be careful when combining strings File + filename + saved. Can t easily be translated QString( File %1 saved. ).arg(filename); % identifiers can be moved by the translation %1 - %99 can be used in any string

96 Using Designer Code Use Private Pointer to Generated Class Private Pointer Advantages Forward declare the generated class Hides dependency on generated header Binary Compatibility Can change.ui file without affecting dependant libraries/apps Remember to delete generated class in destructor Not a QObject; No parent.

97 Private UI Header Class Ui:: CalculatorForm; class CalculatorForm : public QWidget { Q_OBJECT public: CalculatorForm(QWidget *parent = 0); ~CalculatorForm(); private: Ui::CalculatorForm* ui; };

98 Private UI Implementation #include "ui_calculatorform.h" CalculatorForm::CalculatorForm(QWidget *parent) : QWidget(parent) { ui = new Ui::CalculatorForm(); ui->setupui(this); } CalculatorForm::~CalculatorForm() { delete ui; }

99 Threading Tips

100 Threading Tips Use classes that use background processing QNetworkAccessManager, QHostInfo, Sockets, etc Use Qt Event Loops for Producer Consumer You don t have to write syncronization code

101 Event Loop Work Queues Use Per-Thread Qt Event Loops as Work Queues Use cross thread signals and slots to assign work Use cross thread signals and slots to return results Avoids locking the work queue QEventLoop has built-in locks

102 Threading Tips Create a worker thread with run() {exec();} This is the default impl of run() Connect signals to thread slots to dispatch work Connect to thread signals to get results Watch out for QThread s Thread Affinity It belongs to the the thread CREATED it Not a big deal, just use a helper class created in the spawned thread.

103 Event Loop Work Queues connect(this, SIGNAL(workAvailable(WorkType)), thread->worker(), SLOT(doWork(WorkType))); connect(thread->worker(), SIGNAL(workComplete(WorkType)), this, SLOT(processWorkDone(WorkType)) //Auto Connection will cause events to be dispatched to the other thread emit workavailable(work); void processworkdone(worktype) { //Work is received };

104 Event Loop Work Queues class MyThread : public QThread { public: void run() {exec();} Worker* worker(); }; class Worker : public QObject { signals: workcomplete(worktype work); public slots: dowork(worktype work); };

105 General Threading Tips Use QMutex with QMutexLocker Constructor Locks; Destructor Unlocks void exclusivefunction() { QMutexLocker(m_mutex); //Constructor locks } //Destructor unlocks Qt supports Recursive Mutexes Same thread can lock mutex multiple times Must unlock the same number of times Not by default though. Use Recursive in constructor

106 Testing Tips

107 Regression Testing Unit Test using QTest Library Similar to junit and cppunit Can simulate Key and Mouse Events Test Signals with QSignalSpy Functional Test with tools like Squish Script driven application testing Use Q_ASSERT Set breakpoints on qt_assert() DO NOT put functional code in asserts. Only tests.

108 QTest Testing Framework Qt provides the QTestLib framework for testing Qt applications and libraries Lightweight and easy to use Quickly test: Objects Methods and properties GUIs Keyboard and mouse events Signals and slots

109 Doing Tests Various macros provided to report test pass/fail QVERIFY(condition) Verify condition evaluates to true QVERIFY2(condition, message) message is printed if test fails QCOMPARE(actual, expected) Compares using operator=, tries to write actual and expected to test log on failure QSKIP(description, mode) Causes the test to be skipped

110 Widget Testing Functions QTestLib sends internal Qt events to simulate GUI events No side effects on the host machine Key Events keyclick(qwidget* widget, Qt::Key key) keypress(qwidget* widget, Qt::Key key) Mouse Events mouseclick(qwidget * widget, Qt::MouseButton btn, Qt::KeyboardModifiers modifier, QPoint pos) mousemove(qwidget* widget, QPoint pos = QPoint())

111 Widget Testing Example void GuiTest::guiTest() { QLineEdit lineedit; QTest::keyClicks(&lineEdit, "Hello ); QCOMPARE(lineEdit.text(),QString("Hello")); } QPushButton button; QSignalSpy spy(&button, SIGNAL(clicked())); QTest::mouseClick( &button, Qt::LeftButton, Qt::NoModifier, QPoint(1, 1) ); QCOMPARE(spy.count(), 1); //one emitted signal QList<QVariant> args = spy.takefirst(); QCOMPARE(args.size(), 0); //with no args

112 Regression Testing Testing connect can be troublesome Broken Signal/Slot Connections print to stdout at runtime When someone changes/removes signal there is no compile time error. However, the contract has been changed and errors or loss of functionality will result Look for broken signals/slot connections in test outputs from QTest or Squish Or use Q_ASSERT() on the result of connect

113 Regression Testing Use Q_ASSERT to check connect() bool ok = connect(sender, SIGNAL(a()), this SLOT(b())); //Bombs on false in debug binary Q_ASSERT(ok == true); Q_UNUSED(ok) Be sure not to put code in Q_ASSERT Compiled out in release mode

114 Qt 5 Signal and Slot Connection Compile time checked signals and slots Requires C++ 11 connect( sender, &SenderClass::signalFunction reciever, &RecvClass::slotFunction );

115 Effective QML

116 Agenda Building Blocks of QML Declarative Code Creating New Item Types Dynamic Item Creation States Using C++ and QML

117 Building Blocks of QML

118 QObject Heart and Soul of Qt Object Signals and Slots are implemented here QObjects can have child objects Parents have some control over children Deleting them, laying them out, etc Also Qt Properties!

119 Introspection QObjects can report at runtime Class name, Super class Lists of signals and list their arguments Lists of functions and list their arguments Invoke methods by name QMetaObject::invokeMethod(objPtr, function )

120 Meta Object Compiler Introspection info is generated by moc Reads header files. Writes source code moc -o moc_class.cpp class.h MetaObject is static One instance per QObject subclass

121 QQuickItem Most Qt Objects inherit QObject QQuickItem is no exception Gets many of it s features directly from QObject We will be leveraging these capabilities throughout class

122 Qt Properties

123 Qt Properties Combination of Get/Set/Notify Allows introspection system to use these functions as one concept Properties have been in Qt for a very long time Qt Designer is based on properties QML is also based on properties

124 Declaration of a Qt Property #include <QObject> class Car : public QObject { Q_OBJECT Q_PROPERTY(int value READ value WRITE setvalue NOTIFY valuechanged) public: int getvalue() const; void setvalue(int newvalue); signals: void valuechanged(int value); };

125 Declarative Code

126 Basic QML Syntax QML is declarative language With hooks for procedural JavaScript Use as little JavaScript as possible QML files a read at runtime The declarative parts create C++ instances JavaScript is JIT interpreted

127 QtQuick Hello World import QtQuick 2.2 Rectangle{ id: toplevel color: blue Text { text: Hello World } } MouseArea { anchors.fill: parent onclicked: Qt.quit() }

128 Qt Quick Items Rectangle, Text and MouseArea Are implemented in C++ Instances of QQuickRectangle, QQuickText, Etc Loading QML is slower than compiled code At runtime performance is great

129 QML Bindings : is the binding operator Right of the binding operator is JavaScript Text { text: Hello World + Math.rand() } If the expression is simple assignment or call to C++ the interpreter is skipped

130 Bindings are Declarative When any property used in a binding changes the expression is recalculated Gauge { value: Math.min(gaugeMax, Math.max(gaugeMin, oilpressure.value)) } Value is updated whenever properties change gaugemax, gaugemin or oilpressure.value

131 JavaScript is Procedural Avoid this! Gauge { Component.onCompleted: { setgaugevalue(oilpressure.value) oilpressure.valuechanged.connect(setgaugevalue) } ongaugeminchanged: setgaugevalue(value) ongaugemaxchanged: setgaugevalue(value) } function setgaugevalue(oilvalue) { value = Math.min(gaugeMax, Math.max(gaugeMin, oilvalue)) }

132 Broken Bindings Assignment operator breaks bindings Binding works for awhile. Then doesn t. Gauge { id: gauge visible: Dashboard.isOilPressureVisible } } Button { onclicked: { // Tries to temporarily hide gauge if(gauge.visible) gauge.visible = false else gauge.visible = Dashboard.isOilPressureVisible } }

133 Creating New Items

134 Dividing Code Into Components Often a devs to put too much code in one QML file Common issue for all programming languages QML makes it easy to componentize your code Component refers to an item that can be instanced multiple times

135 Creating New Items Simply create a new.qml file Type is named after the filename Must begin with a capital letter Implement Properties Signals Functions

136 Using Custom Component Rectangle{ // Main.qml id: toplevel color: black } Button { text: Click Me onclicked: toplevel.color = white }

137 Custom Button Component Rectangle{ // Button.qml id: button property alias text: label.text signal clicked() color: blue width: 100; height: 50 Text { id: label anchors.centerin: parent } } MouseArea{ id: ma anchors.fill: parent onclicked: button.clicked() }

138 Alias Properties Proxies properties to child items Allows hiding of implementation details Saves memory and binding recalculations

139 Property Scope Public Scope All public properties of the root item Custom properties defined on the root item Private Scope All child items and their properties

140 Rectangle{ // Button.qml id: button property alias text: label.text signal clicked() color: blue Text { id: label anchors.centerin: parent } Public Members } MouseArea{ id: ma anchors.fill: parent onclicked: button.clicked() }

141 Rectangle{ // Button.qml id: button property alias text: label.text signal clicked() color: blue Text { id: label anchors.centerin: parent } Private Members } MouseArea{ id: ma anchors.fill: parent onclicked: button.clicked() }

142 Private Properties Rectangle { // Button.qml id: button property alias text: label.text signal clicked() QtObject { id: internal property int centerx: button.width()/2 } } Text { x: internal.centerx }

143 Dynamic Creation of Items

144 Creating Items Dynamically Procedural Way Component createobject(parent, bindings) function Declarative Way Loader Item Repeater Item ListView / GridView Items

145 Procedural Creation Item { id: screen property SettingDialog dialog: undefined Button { text: Settings... onclicked: { var component = Qt.createComponent( SettingsDialog.qml ) screen.dialog = component.createobject(screen, { anchors.centerin: screen }) screen.dialog.close.connect(screen.destroysettingsdialog) } } function destroysettingsdialog() { screen.dialog.destroy() screen.dialog = undefined }

146 Declarative Creation Item { Button { text: Settings... onclicked: loader.sourcecomponent = dialogcomponent Loader { id: loader anchors.fill: parent } } Component { id: dialogcomponent SettingsDialog { anchors.centerin: parent onclose: loader.sourcecomponent = undefined } }

147 Item { width: 400; height: 400 color: black Grid { x: 5; y:5 rows: 5; columns: 5 Creating Multiple Items } } Repeater { model: 24 Rectangle { width: 70; height: 70 color: lightgreen Text { anchors.centerin: parent text: index } } }

148 Repeater Repeaters can use all types of data models ListModel JSON QList<QObject*> QAbstractItemModel Model data is accessed via attached properties

149 States and Transitions

150 States State Machines can make your code more declarative A basic state machine is built into every Item No sub states or state history

151 States Every Item has a states property States contain Name When Clause List of PropertyChanges{} objects

152 Setting States Item can be set to a give state two ways 1) state property is set to the name of the State item.state = Pressed 2) The when clause of the State is true When clauses must be mutually exclusive They are evaluated in creation order

153 Button States Item { Rectangle { id: bkg; color: blue } MouseArea { id: ma } } states: [ State { name: Pressed when: ma.pressed PropertyChanges { target: bkg; color: red } }, State { name: Disabled when:!(ma.enabled) PropertyChanges { target: bkg; color: grey } } ]

154 Default State The initial bindings are the Default State The name of the default state is Default state is in effect when No when clauses are satisfied state property is set to

155 Properties When in a State The bindings of a QML document is defined as The default state bindings Overlaid with PropertyChanges from the current state This will save you a ton of typing States do not need to be unwound Set common properties in the default state Avoids writing duplicate PropertyChanges

156 Transitions Run animations on a state change Control how properties will change Qt will automatically interpolate values Control in which order properties change

157 Transitions [... ] transitions: [ Transition { from: ; to: Pressed PropertyAnimation { target: bkg properties: color duration: 500 }, Transition { from: * ; to: Disabled PropertyAnimation { target: bkg properties: color duration: 250 } ] [... ]

158 Transition Defaults Transition{} defaults to from: * ; to: * That Transition will apply to all state changes PropertyAnimation When a target is not specified That animation will apply to all items

159 Button Transition Item { Rectangle { id: bkg; color: blue } MouseArea { id: ma } states: [ State { name: Pressed ; when: ma.pressed PropertyChanges { target: bkg; color: red } }, State { name: Disabled ; when:!(ma.enabled) PropertyChanges { target: bkg; color: grey } } ] transitions: [ Transition { PropertyAnimation { properties: color ; duration: 500 } } ]

160 Using C++ and QML

161 Drive QML with C++

162 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

163 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++?

164 Creating Properties in C++ Properties are the combination of Read function Write function Notify signal Signals/slots is Qt s object communication system

165 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(); //Using a parameter is not required by QtQuick };

166 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(); } }

167 Complex Proeprties QObject* can be used as a property Used for encapsulation and creating trees of properties Properties can have properties!

168 Invokable C++ Methods Methods can be called from QML Any slot can be called Any Q_INVOKABLE can be called

169 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++

170 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 };

171 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();

172 Exposing Instances 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(); }

173 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<>()

174 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();

175 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(); }

176 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

177 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

178 Wrapper Reuse Technique Class that provides the QObject interface Inheritance Composition Easier to test Less chance of rocking the boat More typing. More code

179 Wrappers can fix a lot of issues Wrappers can work around limitations 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

180 Model-View-Presenter Pattern Wrappers can be an implementation of MVP Also called Supervising Controller Pattern Provides flexibility between the Model and U Presentation Layer can reformat data Create strings from multiple model values Convert QList<Foo> into an QAbstractItemModel

181 Model View Presenter Presenter Properties Slots View State Changed Get / Set Model

182 Thank You! Justin Noel Senior Consulting Engineer ICS, Inc.

183

SERIOUS ABOUT SOFTWARE. Qt Core features. Timo Strömmer, May 26,

SERIOUS ABOUT SOFTWARE. Qt Core features. Timo Strömmer, May 26, SERIOUS ABOUT SOFTWARE Qt Core features Timo Strömmer, May 26, 2010 1 Contents C++ refresher Core features Object model Signals & slots Event loop Shared data Strings Containers Private implementation

More information

Qt Quick From bottom to top

Qt Quick From bottom to top SERIOUS ABOUT SOFTWARE Qt Quick From bottom to top Timo Strömmer, Feb 11, 2011 1 Contents Day 2 Qt core features Shared data objects Object model, signals and slots, properties Hybrid programming QML fluid

More information

Qt Essentials - Basic Types Module

Qt Essentials - Basic Types Module Qt Essentials - Basic Types Module Training Course Visit us at http://qt.digia.com Produced by Digia Plc. Material based on Qt 5.0, created on September 27, 2012 Digia Plc. Qt's Object Model QObject QWidget

More information

Integrating QML with C++

Integrating QML with C++ Integrating QML with C++ Qt Essentials - Training Course Produced by Nokia, Qt Development Frameworks Material based on Qt 4.7, created on January 18, 2011 http://qt.nokia.com 1/60 Module: Integrating

More information

Praktische Aspekte der Informatik

Praktische Aspekte der Informatik Praktische Aspekte der Informatik Moritz Mühlhausen Prof. Marcus Magnor https://graphics.tu-bs.de/teaching/ws1718/padi/ 1 Your Proposal It s due 17.11.2017! https://graphics.tu-bs.de/teaching/ws1718/padi/

More information

Asynchronous Database Access with Qt 4.x

Asynchronous Database Access with Qt 4.x Asynchronous Database Access with Qt 4.x Dave Berton Abstract How to code around the default synchronous database access in Qt 4. The database support in Qt 4.x is quite robust. The library includes drivers

More information

Qt in Education. Qt Quick

Qt in Education. Qt Quick Qt in Education Qt Quick. 2012 Digia Plc. The enclosed Qt Materials are provided under the Creative Commons Attribution-Share Alike 2.5 License Agreement. The full license text is available here: http://creativecommons.org/licenses/by-sa/2.5/legalcode.

More information

Qt Essentials - Objects Module

Qt Essentials - Objects Module Qt Essentials - Objects Module Training Course Visit us at http://qt.digia.com Produced by Digia Plc. Material based on Qt 5.0, created on September 27, 2012 Digia Plc. Module: Signals & Slots Event Handling

More information

Creating Dynamic UIs with Qt Declarative UI

Creating Dynamic UIs with Qt Declarative UI Creating Dynamic UIs with Qt Declarative UI Alex Luddy 8/25/2010 Purpose To inspire your usage of Qt s declarative UI Show how to use it Show how cool it is 1 Agenda Why Declarative UI? Examples Things

More information

Lab 12: GUI programming with Qt

Lab 12: GUI programming with Qt Lab 12: GUI programming with Comp Sci 1585 Data Structures Lab: Tools for Computer Scientists Outline 1 Outline 1 (Pronounced cute ) https://www.qt.io/what-is-qt/ https://showroom.qt.io/ https://en.wikipedia.org/wiki/_(software)

More information

Rapid Application Development with Qt Quick. Henrik Hartz

Rapid Application Development with Qt Quick. Henrik Hartz Rapid Application Development with Qt Quick Henrik Hartz 1 Agenda Background Structure of a Quick App Hello Elements Integrating with Native code Hello Device Adding New Semantics Hello Widgets 2 Background

More information

Exercises Lecture 2 The Qt Object Model and Signal Slot Mechanism

Exercises Lecture 2 The Qt Object Model and Signal Slot Mechanism Exercises Lecture 2 The Qt Object Model and Signal Slot Mechanism Qt in Education Aim: Duration: This exercise will help you explore the Qt object model (inheritance, properties, memory management) and

More information

Serving QML applications over the network. Jeremy Lainé Wifirst

Serving QML applications over the network. Jeremy Lainé Wifirst Serving QML applications over the network Jeremy Lainé Wifirst Jeremy Lainé Using Qt since 2001 (desktop, mobile, embedded) Occasional Qt contributor (QDnsLookup) Head of software development at Wifirst

More information

+ C++11. Qt5 with a touch of C++11. Matthew Eshleman covemountainsoftware.com

+ C++11. Qt5 with a touch of C++11. Matthew Eshleman covemountainsoftware.com + C++11 Qt5 with a touch of C++11 Matthew Eshleman covemountainsoftware.com Background - Matthew Eshleman 15+ years of embedded software development, architecture, management, and project planning Delivered

More information

Qt Essentials - Fundamentals of Qt Module

Qt Essentials - Fundamentals of Qt Module Qt Essentials - Module Training Course Visit us at http://qt.digia.com Produced by Digia Plc. Material based on Qt 5.0, created on September 27, 2012 Digia Plc. The Story of Qt Developing a Hello World

More information

Qt + Maemo development

Qt + Maemo development ES3 Lecture 11 Qt + Maemo development Maemo Nokia's Linux based platform Almost entirely open source Nokia N770, N800, N810, N900 only models Only N900 has 3G/phone capability N900 has relatively fast

More information

Exercises Lecture 3 Layouts and widgets

Exercises Lecture 3 Layouts and widgets Exercises Lecture 3 Layouts and widgets Aim: Duration: This exercise will help you explore and understand Qt's widgets and the layout approach to designing user interfaces. 2h The enclosed Qt Materials

More information

Why you should be excited about Qt 5

Why you should be excited about Qt 5 Why you should be excited about Qt 5 Thiago Macieira, Qt Core Maintainer Software Architect, Intel OTC Berlin, Nov 13-14, 2012 Santa Clara, Dec 6-7, 2012 Who am I? Open Source developer for 15 years Software

More information

GUI in C++ PV264 Advanced Programming in C++ Nikola Beneš Jan Mrázek Vladimír Štill. Faculty of Informatics, Masaryk University.

GUI in C++ PV264 Advanced Programming in C++ Nikola Beneš Jan Mrázek Vladimír Štill. Faculty of Informatics, Masaryk University. GUI in C++ PV264 Advanced Programming in C++ Nikola Beneš Jan Mrázek Vladimír Štill Faculty of Informatics, Masaryk University Spring 2017 PV264: GUI in C++ Spring 2017 1 / 23 Organisation Lectures this

More information

QML for Desktop Applications

QML for Desktop Applications QML for Desktop Applications Helmut Sedding Michael T. Wagner IPO.Plan GmbH Qt Developer Days Berlin 2012 About us IPO.Plan GmbH Located in Ulm and in Leonberg near Stuttgart The company is both experienced

More information

Qt Essentials - Model View Module

Qt Essentials - Model View Module Qt Essentials - Model View Module Training Course Visit us at http://qt.digia.com Produced by Digia Plc. Material based on Qt 5.0, created on September 27, 2012 Digia Plc. Concept Showing Simple Data Proxy

More information

Core object model EO / EFL++

Core object model EO / EFL++ Core object model EO / EFL++ Carsten Haitzler Samsung Electronics Principal Engineer Enlightenment/EFL Founder c.haitzler@samsung.com EFL + Elementary 2 A toolkit somwhere between GTK+ and Qt in breadth

More information

G52CPP C++ Programming Lecture 9

G52CPP C++ Programming Lecture 9 G52CPP C++ Programming Lecture 9 Dr Jason Atkin http://www.cs.nott.ac.uk/~jaa/cpp/ g52cpp.html 1 Last lecture const Constants, including pointers The C pre-processor And macros Compiling and linking And

More information

Introduction to C++11 and its use inside Qt

Introduction to C++11 and its use inside Qt Introduction to C++11 and its use inside Qt Olivier Goffart February 2013 1/43 Introduction to C++11 and its use inside Qt About Me http://woboq.com http://code.woboq.org 2/43 Introduction to C++11 and

More information

Object-Oriented Programming

Object-Oriented Programming iuliana@cs.ubbcluj.ro Babes-Bolyai University 2018 1 / 33 Overview 1 2 3 4 5 6 2 / 33 I Qt is a cross-platform application and UI framework in C++. Using Qt, one can write GUI applications once and deploy

More information

CopperSpice: A Pure C++ GUI Library. Barbara Geller & Ansel Sermersheim CPPCon - September 2015

CopperSpice: A Pure C++ GUI Library. Barbara Geller & Ansel Sermersheim CPPCon - September 2015 CopperSpice: A Pure C++ GUI Library Barbara Geller & Ansel Sermersheim CPPCon - September 2015 1 Introduction What is CopperSpice Why we developed CopperSpice Drawbacks of Qt Advantages of CopperSpice

More information

Part 1: I don t say Qute! [but I might say Q-awesome ]

Part 1: I don t say Qute! [but I might say Q-awesome ] C++ Unchained: Extending the QML API of ArcGIS Runtime for Qt Mark Cederholm UniSource Energy Services Flagstaff, Arizona 2015 Part 1: I don t say Qute! [but I might say Q-awesome ] What is Qt? Allows

More information

Lecture 10. Implementing User Interface with QML

Lecture 10. Implementing User Interface with QML Title Basic Concepts Background Lecture 10. Implementing with QML Cross-Platform Application Development December 1, 2017 Lecture 10 1 / 67 Main Definitions Beginning Title Basic Concepts Background Definitions

More information

CS 231 Data Structures and Algorithms, Fall 2016

CS 231 Data Structures and Algorithms, Fall 2016 CS 231 Data Structures and Algorithms, Fall 2016 Dr. Bruce A. Maxwell Department of Computer Science Colby College Course Description Focuses on the common structures used to store data and the standard

More information

Lecture 3. COMP1006/1406 (the Java course) Summer M. Jason Hinek Carleton University

Lecture 3. COMP1006/1406 (the Java course) Summer M. Jason Hinek Carleton University Lecture 3 COMP1006/1406 (the Java course) Summer 2014 M. Jason Hinek Carleton University today s agenda assignments 1 (graded) & 2 3 (available now) & 4 (tomorrow) a quick look back primitive data types

More information

Casting -Allows a narrowing assignment by asking the Java compiler to "trust us"

Casting -Allows a narrowing assignment by asking the Java compiler to trust us Primitives Integral types: int, short, long, char, byte Floating point types: double, float Boolean types: boolean -passed by value (copied when returned or passed as actual parameters) Arithmetic Operators:

More information

C++ GUI Programming with Qt 3

C++ GUI Programming with Qt 3 Welcome from Budapest Welcome from ELTE University 1 Rozália Szabó Nacsa Eötvös Loránd University, Budapest Faculty of Informatics nacsa@inf.elte.hu 2 Qt Overview Qt is a complete C++ application development

More information

C++\CLI. Jim Fawcett CSE687-OnLine Object Oriented Design Summer 2017

C++\CLI. Jim Fawcett CSE687-OnLine Object Oriented Design Summer 2017 C++\CLI Jim Fawcett CSE687-OnLine Object Oriented Design Summer 2017 Comparison of Object Models Standard C++ Object Model All objects share a rich memory model: Static, stack, and heap Rich object life-time

More information

Introduction to Visual Basic and Visual C++ Introduction to Java. JDK Editions. Overview. Lesson 13. Overview

Introduction to Visual Basic and Visual C++ Introduction to Java. JDK Editions. Overview. Lesson 13. Overview Introduction to Visual Basic and Visual C++ Introduction to Java Lesson 13 Overview I154-1-A A @ Peter Lo 2010 1 I154-1-A A @ Peter Lo 2010 2 Overview JDK Editions Before you can write and run the simple

More information

NHERI SIMCENTER PROGRAMMING BOOTCAMP JULY 30 THROUGH AUGUST 3, 2018, AT UC BERKELEY S RICHMOND FIELD STATION. GUI Development

NHERI SIMCENTER PROGRAMMING BOOTCAMP JULY 30 THROUGH AUGUST 3, 2018, AT UC BERKELEY S RICHMOND FIELD STATION. GUI Development NHERI SIMCENTER PROGRAMMING BOOTCAMP JULY 30 THROUGH AUGUST 3, 2018, AT UC BERKELEY S RICHMOND FIELD STATION GUI Development OUTLINE GUI Design Fundamentals The Qt Framework Common Data Types/Classes Building

More information

UI, Graphics & EFL. Carsten Haitzler Principal Engineer Samsung Electronics Korea Founder/Leader Enlightenment / EFL

UI, Graphics & EFL. Carsten Haitzler Principal Engineer Samsung Electronics Korea Founder/Leader Enlightenment / EFL UI, Graphics & EFL Carsten Haitzler Principal Engineer Samsung Electronics Korea c.haitzler@samsung.com Founder/Leader Enlightenment / EFL Display System Overview Graphics 4 Graphics Old-School FB 5 In

More information

QT QUICK UI Exam Curriculum

QT QUICK UI Exam Curriculum QT QUICK UI 023-001 Exam Curriculum Qt Quick UI 023-001 2 (5) provides Qt and QML developers with three kinds of certification exams: Qt and QML Essentials Widget UI and Application Engine with Qt Qt Quick

More information

FilePicker, 123 File transfer, 314. GridListLayout, 192 GroupDataModel, 199

FilePicker, 123 File transfer, 314. GridListLayout, 192 GroupDataModel, 199 A AbsoluteLayout, 106 Account methods, PIM, 254 AccountService methods, PIM, 254 account creation, 255 search accounts, 255 Angular displacements, 296 Application structure, 133 action bar, 141 attached

More information

Beyond UX: building solid middleware with Qt (and QML)

Beyond UX: building solid middleware with Qt (and QML) Beyond UX: building solid middleware with Qt (and QML) Qt Developer Days San Francisco, November 2014 Dario Freddi WHO AM I? Fell in love with Qt in KDE, quite a number of years ago Most of my professional

More information

Domain Specific Debugging Tools

Domain Specific Debugging Tools Domain Specific Debugging Tools Volker Krause volker.krause@kdab.com KDAB Problem What's the Problem? So, where's the bug in your QML? Invalid read of size 1 at 0x4C2D9B0: bcmp (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)

More information

file:///home/qt/dev/private/gramakri/presos/final%20logo%20files/tt_devdays07_finallogo.tif Qt Styles and Style Sheets Girish Ramakrishnan

file:///home/qt/dev/private/gramakri/presos/final%20logo%20files/tt_devdays07_finallogo.tif Qt Styles and Style Sheets Girish Ramakrishnan file:///home/qt/dev/private/gramakri/presos/final%20logo%20files/tt_devdays07_finallogo.tif Qt Styles and Style Sheets Girish Ramakrishnan About me Me Girish Ramakrishnan Software Developer + Release manager

More information

Graphical User Interface (GUI)

Graphical User Interface (GUI) Graphical User Interface (GUI) An example of Inheritance and Sub-Typing 1 Java GUI Portability Problem Java loves the idea that your code produces the same results on any machine The underlying hardware

More information

ECE 3574: Dynamic Polymorphism using Inheritance

ECE 3574: Dynamic Polymorphism using Inheritance 1 ECE 3574: Dynamic Polymorphism using Inheritance Changwoo Min 2 Administrivia Survey on class will be out tonight or tomorrow night Please, let me share your idea to improve the class! 3 Meeting 10:

More information

1B1b Classes in Java Part I

1B1b Classes in Java Part I 1B1b Classes in Java Part I Agenda Defining simple classes. Instance variables and methods. Objects. Object references. 1 2 Reading You should be reading: Part I chapters 6,9,10 And browsing: Part IV chapter

More information

What are the characteristics of Object Oriented programming language?

What are the characteristics of Object Oriented programming language? What are the various elements of OOP? Following are the various elements of OOP:- Class:- A class is a collection of data and the various operations that can be performed on that data. Object- This is

More information

Merits of QT for developing Imaging Applications UI

Merits of QT for developing Imaging Applications UI White Paper Merits of QT for developing Imaging Applications UI Amitkumar Sharma January 08, 2008 Trianz 2008 White Paper Page 1 Table of Contents 1.0 Executive Summary. ------------------------------------------------------------------------------------------------------------

More information

G Programming Languages - Fall 2012

G Programming Languages - Fall 2012 G22.2110-003 Programming Languages - Fall 2012 Lecture 2 Thomas Wies New York University Review Last week Programming Languages Overview Syntax and Semantics Grammars and Regular Expressions High-level

More information

G52CPP C++ Programming Lecture 7. Dr Jason Atkin

G52CPP C++ Programming Lecture 7. Dr Jason Atkin G52CPP C++ Programming Lecture 7 Dr Jason Atkin 1 This lecture classes (and C++ structs) Member functions inline functions 2 Last lecture: predict the sizes 3 #pragma pack(1) #include struct A

More information

CERTIFICATE IN WEB PROGRAMMING

CERTIFICATE IN WEB PROGRAMMING COURSE DURATION: 6 MONTHS CONTENTS : CERTIFICATE IN WEB PROGRAMMING 1. PROGRAMMING IN C and C++ Language 2. HTML/CSS and JavaScript 3. PHP and MySQL 4. Project on Development of Web Application 1. PROGRAMMING

More information

Intentions good, warranty void

Intentions good, warranty void Intentions good, warranty void Using Qt in unexpected ways Till Adam / Mirko Böhm Introduction In which MB holds forth and TA smiles and nods... ForegroundLock git.kde.org/kdevplatform/interfaces/foregroundlock.h

More information

Graphical User Interface (GUI)

Graphical User Interface (GUI) Graphical User Interface (GUI) An example of Inheritance and Sub-Typing 1 Java GUI Portability Problem Java loves the idea that your code produces the same results on any machine The underlying hardware

More information

CONTENTS. PART 1 Structured Programming 1. 1 Getting started 3. 2 Basic programming elements 17

CONTENTS. PART 1 Structured Programming 1. 1 Getting started 3. 2 Basic programming elements 17 List of Programs xxv List of Figures xxix List of Tables xxxiii Preface to second version xxxv PART 1 Structured Programming 1 1 Getting started 3 1.1 Programming 3 1.2 Editing source code 5 Source code

More information

CSC209: Software tools. Unix files and directories permissions utilities/commands Shell programming quoting wild cards files

CSC209: Software tools. Unix files and directories permissions utilities/commands Shell programming quoting wild cards files CSC209 Review CSC209: Software tools Unix files and directories permissions utilities/commands Shell programming quoting wild cards files ... and systems programming C basic syntax functions arrays structs

More information

CSC209: Software tools. Unix files and directories permissions utilities/commands Shell programming quoting wild cards files. Compiler vs.

CSC209: Software tools. Unix files and directories permissions utilities/commands Shell programming quoting wild cards files. Compiler vs. CSC209 Review CSC209: Software tools Unix files and directories permissions utilities/commands Shell programming quoting wild cards files... and systems programming C basic syntax functions arrays structs

More information

Reviewing for the Midterm Covers chapters 1 to 5, 7 to 9. Instructor: Scott Kristjanson CMPT 125/125 SFU Burnaby, Fall 2013

Reviewing for the Midterm Covers chapters 1 to 5, 7 to 9. Instructor: Scott Kristjanson CMPT 125/125 SFU Burnaby, Fall 2013 Reviewing for the Midterm Covers chapters 1 to 5, 7 to 9 Instructor: Scott Kristjanson CMPT 125/125 SFU Burnaby, Fall 2013 2 Things to Review Review the Class Slides: Key Things to Take Away Do you understand

More information

MCSA Universal Windows Platform. A Success Guide to Prepare- Programming in C# edusum.com

MCSA Universal Windows Platform. A Success Guide to Prepare- Programming in C# edusum.com 70-483 MCSA Universal Windows Platform A Success Guide to Prepare- Programming in C# edusum.com Table of Contents Introduction to 70-483 Exam on Programming in C#... 2 Microsoft 70-483 Certification Details:...

More information

Qt Essentials - Fundamentals of Qt Module

Qt Essentials - Fundamentals of Qt Module Qt Essentials - Fundamentals of Qt Module Qt Essentials - Training Course Produced by Nokia, Qt Development Frameworks Material based on Qt 4.7, created on December 15, 2010 http://qt.nokia.com 1/28 Module:

More information

12/05/2017. Geneva ServiceNow Custom Application Development

12/05/2017. Geneva ServiceNow Custom Application Development 12/05/2017 Contents...3 Applications...3 Creating applications... 3 Parts of an application...22 Contextual development environment... 48 Application management... 56 Studio... 64 Service Creator...87

More information

Agenda CS121/IS223. Reminder. Object Declaration, Creation, Assignment. What is Going On? Variables in Java

Agenda CS121/IS223. Reminder. Object Declaration, Creation, Assignment. What is Going On? Variables in Java CS121/IS223 Object Reference Variables Dr Olly Gotel ogotel@pace.edu http://csis.pace.edu/~ogotel Having problems? -- Come see me or call me in my office hours -- Use the CSIS programming tutors Agenda

More information

Short Notes of CS201

Short Notes of CS201 #includes: Short Notes of CS201 The #include directive instructs the preprocessor to read and include a file into a source code file. The file name is typically enclosed with < and > if the file is a system

More information

Contents. I. Classes, Superclasses, and Subclasses. Topic 04 - Inheritance

Contents. I. Classes, Superclasses, and Subclasses. Topic 04 - Inheritance Contents Topic 04 - Inheritance I. Classes, Superclasses, and Subclasses - Inheritance Hierarchies Controlling Access to Members (public, no modifier, private, protected) Calling constructors of superclass

More information

Sri Vidya College of Engineering & Technology

Sri Vidya College of Engineering & Technology UNIT I INTRODUCTION TO OOP AND FUNDAMENTALS OF JAVA 1. Define OOP. Part A Object-Oriented Programming (OOP) is a methodology or paradigm to design a program using classes and objects. It simplifies the

More information

PTN-202: Advanced Python Programming Course Description. Course Outline

PTN-202: Advanced Python Programming Course Description. Course Outline PTN-202: Advanced Python Programming Course Description This 4-day course picks up where Python I leaves off, covering some topics in more detail, and adding many new ones, with a focus on enterprise development.

More information

So far, system calls have had easy syntax. Integer, character string, and structure arguments.

So far, system calls have had easy syntax. Integer, character string, and structure arguments. Pointers Page 1 So far, system calls have had easy syntax Wednesday, September 30, 2015 10:45 AM Integer, character string, and structure arguments. But this is not always true. Today, we begin to explore

More information

Weiss Chapter 1 terminology (parenthesized numbers are page numbers)

Weiss Chapter 1 terminology (parenthesized numbers are page numbers) Weiss Chapter 1 terminology (parenthesized numbers are page numbers) assignment operators In Java, used to alter the value of a variable. These operators include =, +=, -=, *=, and /=. (9) autoincrement

More information

CS201 - Introduction to Programming Glossary By

CS201 - Introduction to Programming Glossary By CS201 - Introduction to Programming Glossary By #include : The #include directive instructs the preprocessor to read and include a file into a source code file. The file name is typically enclosed with

More information

Assumptions. History

Assumptions. History Assumptions A Brief Introduction to Java for C++ Programmers: Part 1 ENGI 5895: Software Design Faculty of Engineering & Applied Science Memorial University of Newfoundland You already know C++ You understand

More information

Absolute C++ Walter Savitch

Absolute C++ Walter Savitch Absolute C++ sixth edition Walter Savitch Global edition This page intentionally left blank Absolute C++, Global Edition Cover Title Page Copyright Page Preface Acknowledgments Brief Contents Contents

More information

Socket attaches to a Ratchet. 2) Bridge Decouple an abstraction from its implementation so that the two can vary independently.

Socket attaches to a Ratchet. 2) Bridge Decouple an abstraction from its implementation so that the two can vary independently. Gang of Four Software Design Patterns with examples STRUCTURAL 1) Adapter Convert the interface of a class into another interface clients expect. It lets the classes work together that couldn't otherwise

More information

Java: introduction to object-oriented features

Java: introduction to object-oriented features Chair of Software Engineering Carlo A. Furia, Marco Piccioni, Bertrand Meyer Java: introduction to object-oriented features Chair of Software Engineering Carlo A. Furia, Marco Piccioni, Bertrand Meyer

More information

D Programming Language

D Programming Language Group 14 Muazam Ali Anil Ozdemir D Programming Language Introduction and Why D? It doesn t come with a religion this is written somewhere along the overview of D programming language. If you actually take

More information

Introduction to Design Patterns

Introduction to Design Patterns Introduction to Design Patterns First, what s a design pattern? a general reusable solution to a commonly occurring problem within a given context in software design It s not a finished design that can

More information

Extension of interface signature descriptions for automatic test generation

Extension of interface signature descriptions for automatic test generation Extension of interface signature descriptions for automatic test generation Chernov E. Abstract In the paper the problem of extension of the standard information taken from signatures of program interfaces,

More information

Instantiation of Template class

Instantiation of Template class Class Templates Templates are like advanced macros. They are useful for building new classes that depend on already existing user defined classes or built-in types. Example: stack of int or stack of double

More information

Comprehensive AngularJS Programming (5 Days)

Comprehensive AngularJS Programming (5 Days) www.peaklearningllc.com S103 Comprehensive AngularJS Programming (5 Days) The AngularJS framework augments applications with the "model-view-controller" pattern which makes applications easier to develop

More information

CS121/IS223. Object Reference Variables. Dr Olly Gotel

CS121/IS223. Object Reference Variables. Dr Olly Gotel CS121/IS223 Object Reference Variables Dr Olly Gotel ogotel@pace.edu http://csis.pace.edu/~ogotel Having problems? -- Come see me or call me in my office hours -- Use the CSIS programming tutors CS121/IS223

More information

Qt Quick for Qt Developers

Qt Quick for Qt Developers Qt Quick for Qt Developers States and Transitions Based on Qt 5.4 (QtQuick 2.4) Contents States State Conditions Transitions 2 Objectives Can define user interface behavior using states and transitions:

More information

COPYRIGHTED MATERIAL. Making Excel More Efficient

COPYRIGHTED MATERIAL. Making Excel More Efficient Making Excel More Efficient If you find yourself spending a major part of your day working with Excel, you can make those chores go faster and so make your overall work life more productive by making Excel

More information

Graphical User Interfaces

Graphical User Interfaces Chapter 14 Graphical User Interfaces So far, we have developed programs that interact with the user through the command line, where the user has to call a Python program by typing its name and adding the

More information

Java Object Oriented Design. CSC207 Fall 2014

Java Object Oriented Design. CSC207 Fall 2014 Java Object Oriented Design CSC207 Fall 2014 Design Problem Design an application where the user can draw different shapes Lines Circles Rectangles Just high level design, don t write any detailed code

More information

Qt in Education. Custom Models

Qt in Education. Custom Models Qt in Education Custom Models. 2012 Digia Plc. The enclosed Qt Materials are provided under the Creative Commons Attribution-Share Alike 2.5 License Agreement. The full license text is available here:

More information

Applied Type Erasure in Qt 5. Stephen Kelly KDAB

Applied Type Erasure in Qt 5. Stephen Kelly KDAB Applied Type Erasure in Qt 5 Stephen Kelly KDAB Stephen Kelly KDAB engineer Qt Maintainer (ItemViews, CMake) KDE Developer Many Qt contributions QVariant QMetaType Grantlee - domain specific language Boost

More information

Programming in C++ Prof. Partha Pratim Das Department of Computer Science and Engineering Indian Institute of Technology, Kharagpur

Programming in C++ Prof. Partha Pratim Das Department of Computer Science and Engineering Indian Institute of Technology, Kharagpur Programming in C++ Prof. Partha Pratim Das Department of Computer Science and Engineering Indian Institute of Technology, Kharagpur Lecture - 31 Static Members Welcome to Module 16 of Programming in C++.

More information

C SCI The X Window System Stewart Weiss

C SCI The X Window System Stewart Weiss The X Window System The X Window System is a networking and display protocol which provides windowing on bitmapped displays. X provides the basic framework for building GUI environments, such as drawing

More information

Object-Oriented Programming for Scientific Computing

Object-Oriented Programming for Scientific Computing Object-Oriented Programming for Scientific Computing Smart Pointers and Constness Ole Klein Interdisciplinary Center for Scientific Computing Heidelberg University ole.klein@iwr.uni-heidelberg.de Summer

More information

CSE 70 Final Exam Fall 2009

CSE 70 Final Exam Fall 2009 Signature cs70f Name Student ID CSE 70 Final Exam Fall 2009 Page 1 (10 points) Page 2 (16 points) Page 3 (22 points) Page 4 (13 points) Page 5 (15 points) Page 6 (20 points) Page 7 (9 points) Page 8 (15

More information

Lecture 2, September 4

Lecture 2, September 4 Lecture 2, September 4 Intro to C/C++ Instructor: Prashant Shenoy, TA: Shashi Singh 1 Introduction C++ is an object-oriented language and is one of the most frequently used languages for development due

More information

JScript Reference. Contents

JScript Reference. Contents JScript Reference Contents Exploring the JScript Language JScript Example Altium Designer and Borland Delphi Run Time Libraries Server Processes JScript Source Files PRJSCR, JS and DFM files About JScript

More information

Problem Solving with C++

Problem Solving with C++ GLOBAL EDITION Problem Solving with C++ NINTH EDITION Walter Savitch Kendrick Mock Ninth Edition PROBLEM SOLVING with C++ Problem Solving with C++, Global Edition Cover Title Copyright Contents Chapter

More information

CS11 Advanced C++ Fall Lecture 7

CS11 Advanced C++ Fall Lecture 7 CS11 Advanced C++ Fall 2006-2007 Lecture 7 Today s Topics Explicit casting in C++ mutable keyword and const Template specialization Template subclassing Explicit Casts in C and C++ C has one explicit cast

More information

Design Patterns. (and anti-patterns)

Design Patterns. (and anti-patterns) Design Patterns (and anti-patterns) Design Patterns The Gang of Four defined the most common object-oriented patterns used in software. These are only the named ones Lots more variations exist Design Patterns

More information

Porting applications to Qt. Kevin Funk, Software Engineer KDAB

Porting applications to Qt. Kevin Funk, Software Engineer KDAB Porting applications to Qt Kevin Funk, Software Engineer KDAB What is a migration? Some other toolkit Qt QNX Photon Motif MFC Java AWT Older Qt version Qt5 Why migrate at all? Hard to find developers who

More information

3. Java - Language Constructs I

3. Java - Language Constructs I Educational Objectives 3. Java - Language Constructs I Names and Identifiers, Variables, Assignments, Constants, Datatypes, Operations, Evaluation of Expressions, Type Conversions You know the basic blocks

More information

Highlights. - Making threads. - Waiting for threads. - Review (classes, pointers, inheritance)

Highlights. - Making threads. - Waiting for threads. - Review (classes, pointers, inheritance) Parallel processing Highlights - Making threads - Waiting for threads - Review (classes, pointers, inheritance) Review: CPUs Review: CPUs In the 2000s, computing too a major turn: multi-core processors

More information

Visual Simulation Integration Framework

Visual Simulation Integration Framework Visual Simulation Integration Framework C H R I S T I A N S K L U Z A C E K C E S I U M S O F T W A R E c e s i u m s w @ g m a i l. c o m Objective Who? Why? What? How? When? Where? Who? GSTP-4 Program

More information

COP 3330 Final Exam Review

COP 3330 Final Exam Review COP 3330 Final Exam Review I. The Basics (Chapters 2, 5, 6) a. comments b. identifiers, reserved words c. white space d. compilers vs. interpreters e. syntax, semantics f. errors i. syntax ii. run-time

More information

OpenForms360 Validation User Guide Notable Solutions Inc.

OpenForms360 Validation User Guide Notable Solutions Inc. OpenForms360 Validation User Guide 2011 Notable Solutions Inc. 1 T A B L E O F C O N T EN T S Introduction...5 What is OpenForms360 Validation?... 5 Using OpenForms360 Validation... 5 Features at a glance...

More information

1 Copyright 2011, Oracle and/or its affiliates. All rights reserved.

1 Copyright 2011, Oracle and/or its affiliates. All rights reserved. 1 Copyright 2011, Oracle and/or its affiliates. All rights reserved. ORACLE PRODUCT LOGO Oracle ADF Programming Best Practices Frank Nimphius Oracle Application Development Tools Product Management 2 Copyright

More information

Lecture 03 Bits, Bytes and Data Types

Lecture 03 Bits, Bytes and Data Types Lecture 03 Bits, Bytes and Data Types Computer Languages A computer language is a language that is used to communicate with a machine. Like all languages, computer languages have syntax (form) and semantics

More information

Data Abstraction. Hwansoo Han

Data Abstraction. Hwansoo Han Data Abstraction Hwansoo Han Data Abstraction Data abstraction s roots can be found in Simula67 An abstract data type (ADT) is defined In terms of the operations that it supports (i.e., that can be performed

More information