Table of Contents
Now that we've had a quick look at how basic qtHaskell programs can respond to their input, let's take a closer look at the range of modules, functions and types of the qtHaskell library.
(N.B. by "modules" we mean here Haskell modules or program units. The Qt library itself is divided into modules, i.e. Core, Gui, Network etc. These will be referred to below as Qt modules .)
The modules that make up the qtHaskell library can be divided into two main categories.
Generic modules. These apply to the whole of the qtHaskell library or parts thereof, not to individual Qt classes. For the different types of generic module, there is usually (but not necessarily) one corresponding generic module for each Qt module.
Class Specific modules. These contain the definitions of constructors, methods etc for a specific class.
All qtHaskell modules are in the namespaces Qtc
or
Qth
. The Qtc
namespace contains all
bindings that access the Qt C++ library. The Qth
namespace
contains an implementation of some classes in Haskell which are analogous to
Qt data classes for geometeric objects. Specifically the QRect, QPoint, QLine
and QSize types have equivalent Haskell data types in Qth as Rect, Point,
Line, Size. This will be discussed in more detail later, for now the
important point is that all specific imports of qtHaskell modules begin with
either Qtc
or Qth
.
N.B. There are also modules in the namespaces Qt.Arthur
and Qt.Glome
. These are seen as extra to the
main qtHaskell bindings, although the Qt.Arthur
modules
are included in the main qtHaskell package.
In the Qtc
namespace there are the following types
of generic modules:
Modules in the Qtc.Classes
namespace. These modules
contain Haskell class definitions for the non-static functions of different
Qt classes which share the same method name. There is a
Qtc.Classes.
QtModule
for each Qt module.
If you use Qt classes from a given Qt module e.g. Core, Gui, Network etc, you
will probably need to import the Qtc.Classes.
QtModule
for that Qt module. There is also the
Qtc.Classes.Qccs
module which includes classes for method
names common to more than one Qt module.
Examples: Qtc.Classes.Core, Qtc.Classes.Gui, Qtc.Classes.Qccs.
For each of the above mentioned modules there is an equivalent
Qtc.Classes.
SomeModule
_h.
The "_h" suffixed modules contain class definitions for the handler setting
functions and for the "_h" suffixed function calls to base class methods
which are not unique to a particular Qt class. The Qccs_h
module must be imported if handlers are to be set for any class since the
setHandler
and associated functions use the same name
for all Qt modules.
Examples: Qtc.Classes.Core_h, Qtc.Classes.Gui_h, Qtc.Classes.Qccs_h.
Modules in the Qtc.ClassTypes
namespace. These
modules contain definitions of all the Haskell types which correspond to the
Qt classtypes for a Qt module. They should be included when referring to
the Haskell types explicitly in function signatures, or when they are
subclassed to create custom slots.
Examples: Qtc.ClassTypes.Core, Qtc.ClassTypes.Gui, Qtc.ClassTypes.Opengl.
Modules named Qtc.
SomeQtModuleName
.Base
. These modules contain some commonly
used functions most of which correspond to methods of a class in the
Qt module SomeQtModuleName
.
Examples: Qtc.Core.Base, Qtc.Gui.Base.
The module Qtc.Enums.Classes.Core
contains the class
definitions of enumerated type values that have names common to more than
one enumerated type. Since there are not many of these in Qt they are all
contained in this one module irrespective of which Qt module they belong to.
The module Qtc.Enums.Base
which contains Haskell
conversion functions for enumerated types.
In the Qtc
namespace there are the following types
of class specific modules:
Modules named Qtc.
SomeQtModule.SomeQtClass
. These are the modules that define the Haskell functions for Qt
constructors, static methods, non-static methods and destructors of the
respective class. For classes that have virtual functions there is also a
corresponding Qtc.
SomeQtModule.SomeQtClass
_h module that contains handler setting instances and "_h" suffixed base
class functions for the class.
Examples: Qtc.Core.QFile, Qtc.Gui.QWidget.
Modules named Qtc.Enums.
SomeQtModule.SomeQtClass
. These contain the enumerated type definitions if any exist
for the corresponding Qt class.
Examples: Qtc.Enums.Core.QLineF, Qtc.Enums.Gui.QMessageBox.
The module Qtc.Enums.Core.Qt
which contains
the enumerated type definitions for the C++ Qt
namespace.
Note that the Qth
namespace has a structure
analogous to the Qtc
namespace with a
Classtypes
directory and a per class module for each
class in a Core
directory. It is usually convenient
to use a single import Qth.Core
statement when using
the Qth classes, since they are rarely used in isolation.