Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

cpp-2013 #18 Qt Part 2


Published on

Published in: Technology
  • Be the first to comment

  • Be the first to like this

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