QSortFilterProxyModel* as signal argument is undefined in QML
Solved
QML and Qt Quick
-
Hi,
I have the following class to be used as model for a QMLTableView
class ProcessProxyModel : public QSortFilterProxyModel { Q_OBJECT ... signals: void procModelReady(const ProcessProxyModel* procmodel); private: ProcessProxyModel* m_procModel; }
The class is registered as:
qmlRegisterUncreatableType<ProcessProxyModel>("com.dirac", 1, 0, "ProcessProxyModel", "Type is not allowed to be instantiated");
When the model is ready, I emit a signal as follows:
emit procModelReady(m_procModel);
In QML however, the object passed is not recognized and reported as
undefined
.On the other hand, if I explicitly query for the model via:
Q_INVOKABLE ProcessProxyModel* getProcProxy() const { return m_procModel; }
it works.
To summarize, in QML:
Connections { target: sysmon function onProcModelReady(model) { console.debug(model) // <--- prints undefined console.debug(sysmon.getProcProxy()) //<-- Works correctly }
Why is the signal argument's type not recognized?
-
Hi,
Don't you have any runtime message about an unknown type being used in your signal ?
-
The problem was due to the
const
specifier.signals: void procModelReady(const ProcessProxyModel* procmodel);
Changing it to:
signals: void procModelReady(ProcessProxyModel* procmodel);
works.