3.1 Qt's Widget Class
3.2 Qt and HOOPS/3dGS: The HQWidget Class
3.3 Qt and HOOPS/MVO: Virtual Methods, Signals and Slots
This section provides a brief overview of Qt and the integration of Qt with
HOOPS/3dGS. It assumes familiarity with the Qt toolkit. For more in depth
information on the Qt toolkit, please refer to the book, "Programming
with Qt", from O'Reilly and Associates, ISBN 1-56592-588-2.
The Qt documentation set
is also available in HTML on their website.
Qt is also well known by LINUX users as the basis of KDE - the graphical desktop
environment preferred by most major LINUX distributors.
A widget that isn't embedded in a parent widget is called a top-level widget. Usually, top-level widgets are windows with a frame and a title bar (though it is also possible to create top level widgets without such decoration by the use of widget flags). In Qt, QMainWindow and the various subclasses of QDialog are the most common top-level windows.
A widget without a parent widget is always a top-level widget.
The opposite of top-level widgets are child widgets. Those are child windows in
their parent widgets. You usually cannot distinguish a child
widget from its parent visually. Most other widgets in Qt are useful only as
child widgets. (You can make a e.g. button into a top-level widget, but most
people prefer to put their buttons in e.g. dialogs.) "
Direct manipulation of 3D geometry using a pointing device such as a mouse requires overriding the QWidget virtual methods for mouse events. Keyboard input may be handled in the same manner.
Clear source and a header file are supplied for the class HQWidget and can be directly incorporated into any Qt application. The source code is available in the dev_tools/hoops_qt/source directory of you HOOPS distribution.
The HQWidget can function as either a top-level widget or a child widget.
In the "Signals and Slots" model, user-defined "signals" are "emitted" by the Qt Widgets when activated by the application user, e.g., when a menu button has been clicked on with the mouse. "Slots" are distinct parts of the internal application code. The circuit is complete when the developer "connects" a signal to a slot. Then when the application user activates the GUI element, it generates a signal. The Qt toolkit then looks up the associated slot for the signal and executes the code.
Developers creating applications which operate on 3D geometry are likely to use both of Qt's approaches for processing events. All operations involving direct manipulation with a pointing device, like dynamic rotation of an object, will require overriding the HQWidget's virtual methods for handling low level mouse events. Operations activated with a push button, such as configuring the view's camera to look straight down the z-axis, are best implemented using signals and slots. The HOOPS/Qt integration connects the HOOPS/MVO class library to Qt using both approaches.
The HQWidget Class' main function is to connect to the HOOPS/MVO View Class, used to visually display and interact with the 3D data in the HOOPS/MVO Model Class. The view class has several "push button" methods operating on the model as well as collection of HOOPS/MVO Operator Classes for pointer based, direct manipulation of the model. Only one Operator can be used at any given time for handling the mouse events and it's called the View's "current" operator.
The HOOPS/MVO View Class "push button" methods are connected to Qt menu widgets using signals and slots. The HQWidget's implementation of the virtual methods for low level mouse events calls the view's current operator's mouse handling methods.
The HOOPS/Qt Reference Applications show how to build applications using Qt, the
HQWidget and both of these approaches for connecting the HOOPS/MVO Class
Library to a Qt GUI.