Details
-
Bug
-
Resolution: Unresolved
-
P2: Important
-
6.5
Description
I have ExtraModel that inherits BaseExtraModel,
BaseExtraModel has slot: setNum. When I call it via "ExtraModel *" in QML
all works fine in runtime,
but qmllint reports:
Property "setNum" not found on type "Data::ExtraModel" m.setNum(17); ^^^^^^
I look at mylib.qmltypes and as you see
there is no "proptype: BaseModel" for some reason:
Component { file: "myitem.h" name: "Data::ExtraModel" accessSemantics: "reference" exports: ["example.mylib/ExtraModel 1.0"] exportMetaObjectRevisions: [256] }
C++ part of code:
#include <QQuickItem> namespace Data { Q_NAMESPACE QML_ELEMENT class BaseExtraModel : public QObject { Q_OBJECT QML_ELEMENT public: BaseExtraModel(QObject *parent = nullptr): QObject(parent) {} public slots: void setNum(int p) { qDebug("!!! p=%d", p); } }; class ExtraModel : public BaseExtraModel { Q_OBJECT QML_ELEMENT public: ExtraModel(QObject *parent = nullptr): BaseExtraModel(parent) {} }; } class MyItem : public QQuickItem { private: Q_OBJECT QML_ELEMENT public: MyItem() {} Q_INVOKABLE Data::ExtraModel *model() { return &model_; } private: Data::ExtraModel model_; };
QML:
import QtQuick 2.15 import QtQuick.Window 2.15 import example.mylib 1.0 Window { id: win width: 640 height: 480 visible: true title: qsTr("Hello World") Component.onCompleted: { var m = myItem.model(); m.setNum(17); } MyItem { id: myItem } }
cmake:
Unable to find source-code formatter for language: cmake. Available languages are: actionscript, ada, applescript, bash, c, c#, c++, cpp, css, erlang, go, groovy, haskell, html, java, javascript, js, json, lua, none, nyan, objc, perl, php, python, r, rainbow, ruby, scala, sh, sql, swift, visualbasic, xml, yaml
cmake_minimum_required(VERSION 3.16)
project(hello VERSION 1.0 LANGUAGES CXX)
set(CMAKE_AUTOMOC ON)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
find_package(Qt6 6.2 COMPONENTS Quick Gui REQUIRED)
qt_add_executable(myapp
main.cpp
)
qt_add_qml_module(mylib
URI example.mylib
VERSION 1.0
DEPENDENCIES "QtQuick 2.0"
SOURCES
myitem.cpp
myitem.h
mytablemodel.cpp
mytablemodel.h
)
target_link_libraries(mylib PUBLIC Qt6::Quick)
qt_add_qml_module(myapp
URI hello
VERSION 1.0
IMPORTS example.mylib
QML_FILES
main.qml
)
target_link_libraries(myapp PRIVATE Qt6::Gui Qt6::Quick mylib)