cpp-2013 #18 Qt Part 2

2,590 views
2,562 views

Published on

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
2,590
On SlideShare
0
From Embeds
0
Number of Embeds
6
Actions
Shares
0
Downloads
2
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

cpp-2013 #18 Qt Part 2

  1. 1. Advanced Qt• Qt Creator IDE• Signals/Slots mechanism• Qt meta-system• Parent/child ownership• Copy-on-write• Bonus
  2. 2. Qt Creator IDE - native IDE for Qt• free, open-source and cross-platform• full development cycle out of the box• QtWidget and QtQuick WYSIWYG design tools• fast but multifunctional• VCS integration support• debugging and profiling• project management• Qt help integration• powerful code editor• examples and tutorials• build configuration and management
  3. 3. QObject and QWidgetQObject - central class in Qt• base for most Qt classes• handles signals/slots• keeps meta-data• handles parent/child ownership QWidget - base for all UI classes• handles widgets positioning• any widget can be a separate window• handles UI events (mouse, keyboard etc)• can be simply ported to any platform thanks to Lighthouse
  4. 4. Parent/child ownershipThe problem:• make complex objects lifetime control transparent for developer• prevent memory leaks and referencing deleted objects• prevent removing button while windows still visible The solution:• each QObject may have a parent QObject• parent object knows its children and vice-versa• parent removes its children• parent widget draws its children inside itself
  5. 5. Copy-on-writeThe problem:• containers copying is usually expensive• working with pointers is inconvenient• working with const references decreases readability The solution:• many Qt classes share internal data between object copies• as soon as some object is changed, internal data are copied to prevent changing all objects
  6. 6. Signals/slots• QObjects may emit signals• QObjects void method may be marked as slots• Signals and slots may be connected many-to-many.Benefits:• simple way of communication between objects• objects dont know about each other (no interfaces)• perfectly works in multithreading application• slot call can be queued for async execution• connections can be easily managed in run-time• no configuration needed, just subclass QObject• works across C++, Javascript, QML
  7. 7. Qt meta-system• powered by MOC• stores information about QObject memebers• provides a way to call object method by name• empowers signals/slots mechanism• available via QMetaObject, QMetaProperty, QMetaMethod, QMetaEnum classes• empowers Javascript, QML, plugins• make it possible to have WYSIWYG designer• highly extensible
  8. 8. Out of scope• Model/View architecture in Qt• Styling Qt applications• Animation in Qt applications• Qt Javascript engine• Qt plugins system• New Qt ports coming: WinRT, Android, iOS• Bindings: PyQt, RubyQt, Qt Jambi and more...• Mobile programming• Declarative programming with QtQuick

×