Introduction to Qt Lighthouse

Introduction to Qt Lighthouse

Xu Weidong
2011/7/17

Outline

Qt
Qt feature
Qt port to different graphic system – Lighthouse
Qt object model – QObject and moc
UI design – QWidget and QLayout
Customize widget – Style sheet
Cross-platform project management – qmake

Qt

A cross-platform application and UI framework

Repository:
git://gitorious.org/qt/qt.git

Copyright:
GNU GPL v3
GNU LGPL v2
Commercial licence

History:
1991
1994
Trolltech
Start with support for X11 and Windows
2001
Add support for Mac OS X
2008
Nokia acquired Trolltech
2010
Add support for Symbian

Application developed using Qt:
Autodesk Maya
Google Earth
KDE
Skype
VirtualBox
Methematica

Platform:
Linux/X11
Mac OS X
Windows
Embedded Linux
Windows CE/Mobile
Symbian
Maemo

External mobile target port:
Qt-iPhone
Qt for webOS
Necessitas (Qt for Android)

Qt Feature

Qt framework:
Modular class library
OOP

Qt Creater IDE and tool chain:
Desktop and mobile target
UI designer
Project and build management tools
GNU tool chain

Qt Quick:
QML

Reference:
http://qt.nokia.com/products/library

Qt Lighthouse

Qt for Embedded Linux without QWS
Completely windowsystem-agnostic: all interfacing with window systems is done in plugins

Integrated into Qt 4.8, and it will be the foundation for Qt 5

Components of a platform plugin for Lighthouse:
Plugin integration
Platform screen
Platform window
Platform window surface
etc.

Reference:
http://developer.qt.nokia.com/wiki/Getting_Started_With_Lighthouse
http://developer.qt.nokia.com/wiki/Lighthouse_Architecture

Qt Object Model

Base class:
QObject
Base class for all Qt objects
QEvent
Base class for all event classes

Meta-object system:
QObject as base class
Q_OBJECT macro to enable meta-object features
Meta-object compiler (moc) supplies the necessary code to implement meta-object features

Signals and slots
Object properties
Events and event filers
String translation for i18n
Timers
Object trees

Signals and Slots

An alternative to callback technique
Decoupling of components

Usage:
Define signal at object1, slot at object2
Connect the signal of object1 to the slot at object2
Emit the signal somewhere in object1, and the slot in object2 will be invoked

Notes:
All connection will be automatically disconnected if the sender or receiver is deleted
A signal can be connected to another signal
Duplicate connect is allowed
Signal can be blocked to avoid loop
Objects in different thread can also be connected, then the signal is queued and will be invoked in receiver’s thread

Object Properties

No copy constructor or assignment operator, QObject is treated as an identity, instead of a value
objectName()
findChildren()

Reflection of Qt

QObject:
inherits()
property()
metaObject()

QMetaObject:
newInstance()
className()
superClass()
QMetaMethod: indexOfMethod() / method()
connectSlotsByName()
Auto-connect signals of child objects to its slots of form:
on_<object name>_<signal name>(<signal parameters>)

Reference:
http://doc.qt.nokia.com/latest/object.html
http://doc.qt.nokia.com/latest/metaobjects.html
http://doc.qt.nokia.com/latest/qobject.html
http://doc.qt.nokia.com/latest/qmetaobject.html
http://doc.qt.nokia.com/latest/signalsandslots.html
http://doc.qt.nokia.com/latest/eventsandfilters.html

UI Design

Usage:
All QWidget can be managed by QLayout
setLayout of QWidget or QLayout to set QLayout on it

Layout management:
Position of child widget
Handle of resize
Automatic update when content change

Layout policy:
sizeHint() – Prefered size for the widget
sizePolicy() – How to resize the widget in a layout, if there are extra space, or not enough space

QLayout:
QFormLayout
QGridLayout
QHBoxLayout
QVBoxLayout

Reference:
http://doc.qt.nokia.com/latest/layout.html
http://doc.qt.nokia.com/latest/widgets-and-layouts.html

Style Sheet

Set on:
Application
Widget

Customize by:
Widget with certain class, subclasses
Widget with certain object name
Sub-control of some widget
Widget state (hover, press, etc.)

Reference:
http://doc.qt.nokia.com/latest/stylesheet.html

Project Managerment

Usage:
Call “qmake -project” to generate
Platform independent project file
<project name>.pro
Call “qmake” to generate
Platform dependent make file Makefile
Call “make” to build target
Project Managerment

Reference:
http://doc.qt.nokia.com/latest/qmake-manual.html

Advertisements
This entry was posted in Computer and Internet. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s