cmannett85
cmannett85

Reputation: 22346

Invalid signal parameter type: MouseEvent

If I try and use a MouseEvent as an arg in a QML defined signal, I get the following error on load:

Invalid signal parameter type: MouseEvent

There is conflicting information in the Qt docs regarding this, in the QML signal syntax documentation it states that:

The allowed parameter types are the same as those listed under Defining Property Attributes [...] any QML object type can be used as a property type.

Whilst in the QML/C++ interaction documentation it states that:

When a QML object type is used as a signal parameter, the parameter should use var as the type

Setting the argument to use var does work, but this seems unnecessary according to the QML documentation. There was a bug regarding this in the distant past but it was apparently resolved in v5.0.0. So I am doing something wrong, or is this a regression?

Edit

A simple demonstration:

import QtQuick 2.3

Item {
    signal sig( MouseEvent mouse )
}

Upvotes: 6

Views: 1551

Answers (1)

S.M.Mousavi
S.M.Mousavi

Reputation: 5226

Use QtObject instead

signal sig(QtObject mouse)

Note: This works because QtObject is plain QObject which is base of all Qt objects

Upvotes: -1

Related Questions