3.3. Types

3.3.1. Types of Types

QtHaskell types corresponding to a Qt class QSomeQtClass have the format QSomeQtClass a. They are implemented as shadow types and hence if a parameter in a qtHaskell function has the type QSomeQtClass a then any object can be passed that whose qtHaskell type corresponds to the Qt type QSomeQtClass or any subclass thereof. If subclass types are not required for a parameter of a qtHaskell application function then the type QSomeQtClass () should be used.

All qtHaskell types whose corresponding Qt baseclass is QObject also have a qtHaskell type QSomeQtClassSc. This type should only be used when subclassing a qtHaskell type to add custom slots or signals as in section 2.2. E.g.

  type MyQDialog = QWidgetSc (CMyQDialog)

Qt enumerated and flags types have the C++ format QSomeQtClass::SomeQtEnumeratedOrFlagsType. The corresponding qtHaskell type is usually just SomeQtEnumeratedOrFlagsType. In the case where the same enumerated or flags types name is shared by more than one class, the qtHaskell type is SomeQtClassSomeQtEnumeratedOrFlagsType. E.g.

  mb <- qMessageBox (eNoIcon::Icon, "", "", fNoButton::QMessageBoxStandardButtons, dialog)

3.3.2. qCast

QtHaskell objects can be converted from one type to another without restriction. For each qtHaskell class type there is a corresponding function qCast_SomeQtClass obj. This converts an object obj of any class type to type SomeQtClass with the returned value having the same internal pointer value as obj. This function should be used with caution.