1.0 Introduction

2.0 What is Qt?

3.0 Integrating Qt with the HOOPS 3D Application Framework

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


1.0 Introduction

The HOOPS/Qt Integration module connects the HOOPS 3D Graphics System to the Qt GUI toolkit, available from Troll Tech. The combination of Qt with HOOPS/3dGS  enables developers to rapidly build cross-platform applications with advanced 3D capabilities and professional GUI functionality.

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.


2.0 What is Qt?

Qt is a cross-platform user interface framework available from Troll Tech, located in Oslo, Norway. It provides application developers with all the functionality needed to build state-of-the-art, professional graphical user interfaces. Qt is fully object-oriented, easily extensible and allows true component programming. It is fully supported on Windows 95/98/NT, Sun Solaris, HP-UX, Digital Unix, IBM AIX, SGI IRIX, Linux and a wide range of other platforms. Since 1994, Qt has formed the basis of hundreds of successful applications worldwide.

Qt is also well known by LINUX users as the basis of KDE - the graphical desktop environment preferred by most major LINUX distributors.


3.0 Integrating Qt with HOOPS 3dGS

Integrating Qt with HOOPS/3dGS primarily consists of creating a custom widget derived from the QWidget class and overriding several of the QWidget's virtual methods to add functionality required to connect HOOPS/3dGS to the widget. Qt's C++, object oriented implementation makes creating such a custom widget very straightforward. Once the widget has been designed and implemented, the next step is to integrate the internal application code with the Qt toolkit's event processing model. 

3.1 Qt's QWidget Class

The QWidget class is the base class for all Qt user interface objects. The following description of the QWidget class is an excerpt from the Qt documentation:
"The widget is the atom of the user interface: It receives mouse, keyboard and other events from the window system, and paints a representation of itself on the screen. Every widget is rectangular, and they are sorted in a Z-order. A widget is clipped by its parent and by the widgets in front of it. 

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.) "

 

3.2 Qt & HOOPS/3dGS: The HQWidget Class

The HOOPS/Qt integration supplies a custom widget derived from QWidget called HQWidget. The implementation supplies methods for configuring the system resources like X11 colormaps and visuals,  MSWindows color palettes and passing this information to the HOOPS/3dGS. It also provides methods that ensure the custom widget responds correctly to low-level windowing system events such as resize and paint.

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.


3.3 Qt & the HOOPS/MVO Class Library: Virtual Methods, Signals and Slots

Qt uses two separate methods for processing events generated by a user's interaction with the GUI. The first method is to define a set of virtual methods on the QWidget class that must handle low level "syntactical" events from the windowing system such as "Paint", "Resize", "Key Press", and "Mouse Movement". The second method is a higher level approach invented by the Qt development team called "Signals and Slots" and can be used to handle high level or "syntactical" events.

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.