L8: Qt4 Concept Qt Module QObject QObject Model Signal and Slot Qt Event Loop.

Slides:



Advertisements
Similar presentations
First Steps with Qt Julien Finet Kitware Inc. Jan. 05 th 2010.
Advertisements

Lecture 4: Embedded Application Framework Qt Tutorial Cheng-Liang (Paul) Hsieh ECE 424 Embedded Systems Design.
QT GUI Programming CS340 – Software Design © 2009 – Jason Leigh University of Illinois at Chicago.
Solutions to Review Questions. 4.1 Define object, class and instance. The UML Glossary gives these definitions: Object: an instance of a class. Class:
CSE 1302 Lecture 8 Inheritance Richard Gesick Figures from Deitel, “Visual C#”, Pearson.
(C) 2010 Pearson Education, Inc. All rights reserved. Java™ How to Program, 8/e.
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 13 Introduction to SQL Programming Techniques.
1 Frameworks. 2 Framework Set of cooperating classes/interfaces –Structure essential mechanisms of a problem domain –Programmer can extend framework classes,
1 Evan Korth New York University Inheritance and Polymorphism Professor Evan Korth New York University.
ASP.NET Programming with C# and SQL Server First Edition
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 11 Object and Object- Relational Databases.
System Design Decomposing the System. Sequence diagram changes UML 2.x specifications tells that Sequence diagrams now support if-conditions, loops and.
C++ fundamentals.
Qt Igor November 8, 2002 Friday’s HENP Group Meeting.
OOP Languages: Java vs C++
INTRODUCTION TO WEB DATABASE PROGRAMMING
Hands-on Introduction to Visual Basic.NET Programming Right from the Start with Visual Basic.NET 1/e 6.
.NET Framework Introduction: Metadata
INTRODUCTION TO PROGRAMMING STRUCTURE Chapter 4 1.
Lecture 8 Inheritance Richard Gesick. 2 OBJECTIVES How inheritance promotes software reusability. The concepts of base classes and derived classes. To.
An Introduction to Software Architecture
Welcome to CIS 083 ! Events CIS 068.
CNIT 133 Interactive Web Pags – JavaScript and AJAX JavaScript Environment.
By Lecturer / Aisha Dawood 1.  You can control the number of dispatcher processes in the instance. Unlike the number of shared servers, the number of.
Getting Started The structure of a simple wxWidgets program, Look at where and how a wxWidgets application starts and ends, how to show the main window,
CHAPTER TWO INTRODUCTION TO VISUAL BASIC © Prepared By: Razif Razali 1.
More on Hierarchies 1. When an object of a subclass is instantiated, is memory allocated for only the data members of the subclass or also for the members.
 2002 Prentice Hall, Inc. All rights reserved Introduction Graphical User Interface (GUI) –Gives program distinctive “look” and “feel” –Provides.
® Microsoft Access 2010 Tutorial 10 Automating Tasks with Macros.
Programming in Java CSCI-2220 Object Oriented Programming.
Object Oriented Software Development
ECE450 - Software Engineering II1 ECE450 – Software Engineering II Today: Design Patterns VIII Chain of Responsibility, Strategy, State.
Chapter 6 Introduction to Defining Classes. Objectives: Design and implement a simple class from user requirements. Organize a program in terms of a view.
Creating a Qt Widget Based Application From Qt Creator Manual.
Introduction to c++ programming - object oriented programming concepts - Structured Vs OOP. Classes and objects - class definition - Objects - class scope.
Confidential © 2008 Teleca AB Creating Custom Widgets Author: Patricia Jiang Date: July 29, 2010 Version: 1.0 Teleca Chengdu.
Chapter 5 Introduction to Defining Classes
QT Programming QT Programming Ruku Roychowdhury. Background QT is a cross platform application framework. Widely used to develop GUI applications. Originally.
GUIs Basic Concepts. GUI GUI : Graphical User Interface Window/Frame : a window on the screen Controls/Widgets : GUI components.
CS212: Object Oriented Analysis and Design Lecture 16: Runtime Polymorphism.
Inheritance and Class Hierarchies Chapter 3. Chapter 3: Inheritance and Class Hierarchies2 Chapter Objectives To understand inheritance and how it facilitates.
Object-Oriented Programming: Inheritance and Polymorphism.
THE EYESWEB PLATFORM - GDE The EyesWeb XMI multimodal platform GDE 5 March 2015.
Copyright © 2016 Ramez Elmasri and Shamkant B. Navathe Chapter 12 Outline Overview of Object Database Concepts Object-Relational Features Object Database.
LCG AA Meeting 30 June 2004 Ilka Antcheva Graphics User Interface in ROOT.
12-Jun-16 Event loops. 2 Programming in prehistoric times Earliest programs were all “batch” processing There was no interaction with the user Input Output.
Chapter 5 Introduction to Defining Classes Fundamentals of Java.
Java Programming: Guided Learning with Early Objects Chapter 9 Inheritance and Polymorphism.
©TheMcGraw-Hill Companies, Inc. Permission required for reproduction or display. Chapter 7 Event-Driven Programming and Basic GUI Objects.
1. 2 Qt Toolkit ● C++ toolkit for cross-platform GUI application development – GUI functions (GUI = graphical user interface) – Data access components,
Class Inheritance Part II: Overriding and Polymorphism Corresponds with Chapter 10.
The BLISS Framework 4.
File System Implementation
Event loops 16-Jun-18.
HCI/CHI: Computer-Human Interaction
CS212: Object Oriented Analysis and Design
Chapter 12 Outline Overview of Object Database Concepts
Event Driven Programming
Lecture 22 Inheritance Richard Gesick.
Event loops.
Custom Widgets & Events
Java – Inheritance.
An Introduction to Software Architecture
Event loops 17-Jan-19.
Event loops 17-Jan-19.
Object-Oriented Programming: Inheritance and Polymorphism
Event loops 8-Apr-19.
Event loops.
Event loops.
Event loops 19-Aug-19.
Presentation transcript:

L8: Qt4 Concept Qt Module QObject QObject Model Signal and Slot Qt Event Loop

Qt Modules The main five Qt 4 modules are  Core: QObject, QThread, QFile, etc.  GUI: all classes derived from QWidget, and some related classes  XML for parsing and serializing XML  SQL for communicating with SQL databases  NET for communicating data between hosts on specific protocols.

Qt Object (I) The base class of all Qt objects. Its class name can be found via the corresponding QmetaObject::className(). Has a unique QObject::objectName(). Has a location in an object hierarchy. Can be connected to other Qt Objects to emit signals to them or to receive signals emitted by them. Can have new properties added to it at runtime that are not declared in the C++ class. Q_OBJECT macro is mandatory for any object that implements signals, slots or properties.

Qt Objects (II) Qt Objects should be treated as identities, not as values. Identities are cloned, not copied or assigned, and cloning an identity is a more complex operation than copying or assigning a value. Therefore, QObject and all subclasses of QObject (direct or indirect) have their copy constructor and assignment operator disabled.

Qt Object Model (I) Qt Object Model adds these features to C++: A mechanism for seamless object communication called signals and slots. Queryable and designable object properties. Event filters. Contextual string translation for internationalization.

Qt Object Model (II) Qt Object Model adds these features to C++: Interval driven timers that make it possible to integrate many tasks in an event-driven GUI. Hierarchical and queryable object trees that organize object ownership in a natural way. Quarded pointers (QPointer) that are automatically set to 0 when the referenced object is destroyed. A dynamic cast that works across library boundaries.

Signal and Slot (I) A mechanism for communication between objects A signal is emitted when a particular event occurs. A slot is a function that is called in response to a particular signal.

Signal and Slot (II) The signals and slots mechanism is type safe: the signature of a signal must match the signature of the receiving slot. A slot may have a shorter signature than the signal it receives because it can ignore extra arguments. Since the signatures are compatible, the compiler can detect type mismatches.

Signal and Slot (III) Signals and slots are loosely coupled: a class which emits a signal neither knows nor cares which slots receive the signal. More than one signal can be connected to a single slot, and a signal can be connected to many slots (many-to-many). It is even possible to connect a signal directly to another signal. (This will emit the second signal immediately whenever the first is emitted.)

Example: Diagram Object A emits a signal. A slot in object B is called in response to this signal.

Example: Header (I)

Example: Header (II)

Example: Source

Example: Main

Qt Event Loop: Basic Concept  QEvent encapsulates the notion of an event.  QEvent is the superclass of several specific event classes such as QActionEvent, QFileOpenEvent, QMouseEvent, etc.  QEvent objects can be created by the window system in response to actions of the user (e.g., QMouseEvent), at specified time intervals (QTimerEvent), or explicitly by an application program.

Qt Event Loop: Basic Concept An event loop is a program structure that permits events to be prioritized, enqueued, and dispatched to objects. The event loop generally continues running until a terminating event occurs (e.g., the user clicks on Quit).

Qt Event Loop: The Crowd Goes Wild  A Qt program creates objects, connects them, and then tells the application to exec(). At that point, the objects can send information to each other in a variety of ways.  QWidgets send QEvents to other QObjects in response to user actions such as mouse clicks and keyboard events.  A widget can also respond to events from the window manager such as repaints, resizes, or close events.  QObjects can transmit information to one another by means of signals and slots.

References Qt.Nokia (2011). Qt Reference Documentation [Online]. Available from: [Accessed: 22 January 2011] Ezust, A. & Ezust, P. (2006). An Introduction to Design Patterns in C++ with Qt 4. (1 st ed.). New York: Prentice Hall. Blanchette, J. & Summerfield, M. (2008). C++ GUI Programming with Qt 4. (2 nd ed.). New York: Prentice Hall.