See UNISA – Summary of 2010 Posts for a list of related UNISA posts. Continued from UNISA Chatter – Design patterns in C++ Part 4: Widgets … getting started with the QT User Interface.

IMPORTANT POINT: It is important to emphasize that the intent of these posts are to share my learning's as I dig through the last three subjects of my part-time UNISA studies. The posts by no means promote concepts or technologies … they are pure information sharing for fellow students … although the highlight that we explore more technologies and concepts that we typically prefer :)CLIPART_OF_10887_SM_thumb[3][5]

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
QProcess

Class that is used to spawn another process. Some important notes:

  • Runs program in a separate memory space.
  • Communication via streams between child and parent.
  • Processes are managed by the operating system.
  • Processes are spawned with the start method and terminated with the terminate method.

class MyProcess : QProcess
{
    Q_OBJECT
    …
}

QThread

Class used to spawn another thread. Some important notes:

  • Runs thread in the same memory space as the host process.
  • Communication via shared memory.
  • Synchronization using locks, wait conditions, mutexes and semaphores.
  • Threads are managed by the host process,

class MyThread : QThread
{
    Q_OBJECT
    ….
}

QMutex

Used for mutual exclusion, allowing threads to protect (lock) an object or sections of code.

 
QWaitCondition

Combined with QMutex, QWaitCondition can be used to place threads into non-busy block state and wait to be woken up by another thread.

 
QSemaphore

QSemaphore is used to lock more that one resource and to ensure that threads only lock available resources.

 

Here is the simple example application I created … two threads creating hypothetical stock prices:

image image

Shout if you would like the C++ source code.