Chapter 2. Differences from Qt4 C++ API

Table of Contents

C++ Enum Types
Comparations (switch/case)
Arguments in Pure Virtual Methods
QApplication
QCoreApplication
QEvent
QHash
QList
QMap
QMultiMap
QString
QVariant
Related Non-Members - QGlobalSpace
Operators
Constants
Additional Functions

In this part of documentation will be described differences from C++ API.

Qore Qt4 module is using Smoke libraries as a C++ bridge to the Qt library. When there is any feature missing it's in most cases Smoke design concept – QStrings, QMaps, etc. are missing by design. It's not a bug.

Qore can be used as a weakly typed language so it can allow to define variables with no strict types as it's in C++. For example the following code is correct and will work in the Qore Qt4 scripts:

Example 2.1. Weakly typed auto-conversions

my $var = 10;
my $lineEdit = new QLineEdit();
$lineEdit.setText( $var );
      

Method's (function's) input arguments are converted as much as it's possible in this case.

Note

Since Qore 0.8.0 there can be used strong typed code -- consult Qore Language Reference. Using this feature is strongly recomended for bigger software projects as it can help you to avoid errors.

C++ Enum Types

C++ enums are handled by special Qore QtEnum type in its internal implementation. There are no special requirements how to deal with enums except some special cases.

You should use type Integer if you are using strong typed variables: my int $e = QDialog::Accepted;

Comparations (switch/case)

Qore uses hard comparation method for switch case construct so using QtEnum with eg. Type::Int won't work in this case.

Read Qore documentation, chapter switch Statements for more information.

Example 2.2. QtEnum and Type::Int handling

# reimplementation of QAbstractItemModel::data(QModelIndex, int)
MyModel::data ( $index, $role )
{
    if (!$index.isValid())
        return;

    switch ($role)
    {
        # wrong
        case Qt::DisplayRole :
            printf("This is wrong. QtEnum and Type::Int are not comparable with hard-comparation\n");
            return "this will be never called";
        # good
        case == Qt::ToolTipRole :
            printf("This is correct. Comparation is enforced to use soft-comparation\n");
            return "some data to display in tool tip";
    }
}