Hi all,
I built an QML extension plugin for reusability.
I linked it to my app project. No problem during execution. Everything works fine except...code completion within QtCreator : my custom QML type (defined in a QML file, not a QML binding from C++) isn't recognized by the QML editor. It's very frustrating.
Here's my project's structure :
src
-- app
---- some things
---- qml.qrc
------ main.qml // error M300
-- libs
---- customquick // Folder of QML plugins
------ controls // my extension plugin
-------- customquickcontrolsplugin.(h/cpp)
-------- gridmenulogic.(h/cpp) // C++ binding class
-------- GridMenu.qml // the type which isn't recognized in main.qml
-------- qmldir
My qmldir :
module customquick.controls
GridMenu 1.0 GridMenu.qml
plugin customquickcontrolsplugin
classname CustomQuickControlsPlugin
module customquick.controls
GridMenu 1.0 GridMenu.qml
plugin customquickcontrolsplugin
classname CustomQuickControlsPlugin
To copy to clipboard, switch view to plain text mode
main.qml
import QtQuick 2.2
import QtQuick.Window 2.1
import customquick.controls 1.0
Window {
visible: true
width: 360
height: 360
GridMenu { // <-- M300 error
id: menu
anchors.fill: parent
}
}
import QtQuick 2.2
import QtQuick.Window 2.1
import customquick.controls 1.0
Window {
visible: true
width: 360
height: 360
GridMenu { // <-- M300 error
id: menu
anchors.fill: parent
}
}
To copy to clipboard, switch view to plain text mode
GridMenu.qml
import QtQuick 2.0
import customquick.controls 1.0
Item {
width: 100
height: 80
GridMenuLogic {
}
}
import QtQuick 2.0
import customquick.controls 1.0
Item {
width: 100
height: 80
GridMenuLogic {
}
}
To copy to clipboard, switch view to plain text mode
And my CustomQuickControlsPlugin class :
void CustomQuickControlsPlugin::registerTypes(const char *uri)
{
// @uri controls
qmlRegisterType<GridMenuLogic>(uri, 1, 0, "GridMenuLogic");
}
void CustomQuickControlsPlugin::registerTypes(const char *uri)
{
// @uri controls
Q_ASSERT(uri == QLatin1String("customquick.controls"));
qmlRegisterType<GridMenuLogic>(uri, 1, 0, "GridMenuLogic");
}
To copy to clipboard, switch view to plain text mode
The project copies the .qml files to the build directory and I setted the "QML2_IMPORT_PATH" environment var. But GridMenu is still underlined in main.qml...
I works with QtCreator 3.2.0 and Ubuntu 14.04.
Thanks for your help.
Bookmarks