See UNISA – Summary of 2010 Posts for a list of related UNISA posts. Continued from UNISA Chatter – UNISA Chatter – Design patterns in C++ Part 3: Generics & Serializer Pattern .
QT and Environment Summary
The following is a summary of findings as I worked through the course related book. See the summary post for details on the book.
|Terminology ||Description ||Example |
|QWidget || |
Class using multiple inheritance, as shown, making it paintable and an object that can have parents and all the other goodies shipped with QObject.
There are different classes of QWidgets:
QPushButton, QToolButton, QCheckBox, QRadioButton
QComboBox, QLineEdit, QTextEdit, QSlider, QTimeEdit, QDateEdit, QSpinButton, QScrollBar
QPixMap, QLabel, QProgressBar
QMainWindow, QFrame, QToolbar, QTabWidget, QStacketWidget, QFileDialog, QInputDialog, …
|QMainWindow || |
QMainWindow is the mother of all windows, the main window, and therefore the parent of all other widgets in the main window. Most QApplication objects, we introduced in previous posts, manage one of these QMainWindow objects.
|QSettings || |
QSettings is used to save and restore application state, using a persistent map of value and key pairs.
|QMessageBox || |
Something that I am pondering over, but actually liking, is the apparent overlap and similarity with Win32 and .NET classes. The QMessageBox just brought back so many memories … it is used, as in the other mentioned environments, to popup a standard dialog.
|QMessageBox::question(this,”if it is neither here nor there, where is it?”, “interesting”, 0, –1); |
|Images and Resources || |
To include binary files, such as images, in our Qt application we follow a few easy steps:
Create a Resource Collection File (.qrc) that is an XML file that lists all of the binary files.
Generate a resource file (rcc) using a Python script
Add a RESOURCE line in the project file that defines the name of the qresource file.
… or we can simply use the IDE.
See the sample solution for examples.
|Layout || |
To control the layout of the windows we can use the following classes, amongst others:
Layout (must have a QWidget or QLayout parent)
Spacing (fixed number of pixles)
Stretch (stretchable number of pixles)
Structs (minimum size of perpendicular dimension)
See the sample solution for examples.
Design Pattern Summary
|Terminology ||Description |
|Pattern: Monostate || |
- Creational design pattern
- Allows multiple instances of an application to share the same one (mono) state.
- It is an implementation of the Singleton pattern.
… the Visual Studio class diagram emerges :) Sanity prevails.
|Pattern: Command || |
- Behavioural design pattern
- Encapsulates commands/operations in as objects with a common interface, making it possible to operations, log operations and implement features such as undo, redo and transactions.
The will post the sample solution I developed as soon as I submit the assignment, which use most of the QT features summarised above. When I am done with UNISA, I will probably rewrite all of these samples using Visual Studio 2010 and demonstrate the phenomenal features and productivity of that environment as well.
Here are a few screen shots, which should highlight the favourite sample program emerging through the technology forest once again:
… 8! = 512 … it even works :)
I once had lots of fun writing the code and debugging the gremlins and odd behaviours using the QT IDE. Not sure what the problem is, but there are often locked files, especially after a debug session, forcing an IDE restart … brings back memories from very early Visual Studio builds and can be rather tiring late at night.
Next post will explore the QVC pattern … a pattern that has also settled firmly in Visual Studio 2010 samples. If only we could complete these assignments using Visual Studio 2010 :|