Creator Design mode doesn't show the QML components coming from a plugin
-
Hi,
I built a qml plugin where I created a Image.qml file that just extends the original Image qml component.
My Image.qml:
@
import QtQuick 1.0Image {
id:root}
@The issue I have is that it doesn't show up in the Design mode when I use it.
my test file :
@import QtQuick 1.0
import com.mpsa.components 2.0Rectangle {
width: 400
height: 400Image { source: "picto.png" }
}
@In the design mode I just get a full white preview....
But if I comment the "import com.mpsa.components 2.0" line it will the Image from QtQuick and will appear in the Designer.
So is there something special to do to get components from a qml plugin appear in the design mode ?
-
I have the same problem and it is a little discouraging to see that there does not seem to be a solution. Does anyone know how the Design mode really works and how it resolves its imports.
The problem does not seem to exist when you import something from Qt like QtQuick.Controls 1.0. Somehow one must be able to tell Design mode additional imports. Does it take a QtCreator plugin to accomplish this?
Thanks
-
Qt Quick Designer uses an external process called qml(2)puppet for the rendering. In the latest SDK we ship qml(2)puppet as part of Qt and use those.
This is why rendering QtQuick.Controls works even though they are not shipped together with Qt Creator. Qt Creator might even be build with Qt 4.
The Qt Quick Designer uses the QML code model to resolve imports, so the QML code model has to "know" the plugin. There is a tool called qmlplugindump for this.
For the rendering to work, the Qt currently configured for the project, has to know about the plugin and has to have a qml(2)puppet.
The safest way is to install the plugin for your import in your Qt like we do it for e.g. QtQuick.Controls.
Setting QML_IMPORT_PATH is another option. Also .pro and .qmlproject files support setting additional import paths for QML.
The qml(2)puppet is usually build in release mode, so you also have to make sure you plugin has a release version.
If your plugin is a pure QML plugin (no C++) just setting the correct import path in the .pro or .qmlproject file works.
-
Thank you for your help
It took me a while to implement your suggestions, but that was mostly due to not getting plugins to work at all.
One problem arose because I have a declarative project that has a main method where I use an Instance of a class that inherits from QDeclarativeView which then loads my qml files.
In this case the QML_IMPORT_PATH does not do any good. Neither the IDE nor the actual running programm knows about my plugin.
but:
@view.rootContext()->engine()->addImportPath("c:/.../importPath");@
(view is a QDeclarativeView)is doing the trick at least for the running program. But not for the design mode. If I try to import it somewhere in a .qmlproject based project, the design mode works perfectly.
By the way importing a module like QtTest results in components not being displayed as well. So I think i am missing something fundamental.
-
I have exactly the same problem. I played around with qmldump and co and it was not able to get my components into the Qt Designer. Can you please take a look at my code to figure out what I am doing wrong? Btw. I also copy the plugins inside the Qt folder and they are recognized by Qt Creator (just not showing up in Qt Designer). I studied the code from QtQuick.Controls but was able to find out what it does differently.
What I actually try to achieve is to get a entry in Qt Designer with a custom name e.g. Machinekit - Controls.
-
Yep, same problems here, too.
- What is necessary to preview own QtQuick controls at design time in QtQuick Designer? If I define a QML Control, eg. Control.qml, then I can drag and drop it in QtQuick Designer to the canvas. But there is no preview rendering available. In my case, Control.qml uses a QMLCanvas to render complex painter code. But very simple controls doesn't have a preview too..
-> Is it necessary to wrap my controls in a plugin, even they only consists of one QML File without any C++ extensions?
- Is there a way to provide a kind of "design-time" implementation for each control, which is used by QtQuick designer to render the preview?
Thank you very much in advance!
Frime -
There is a small test case that shows how to integrate a pure qml plugin in the designer and adding the items to the item library:
bq. Is there a way to provide a kind of “design-time” implementation for each control, which is used by QtQuick designer to render the preview?
This is something we plan to do. My current workaround would be to provide a .qmlproject file with a different import path for the mockup plugins.
-
Thank you very much! That helped me a lot :)
-
Hi again!
I tried two different QtCreator versions, 3.2.2 and 2.8.1 .. The older one is able to render the preview, but doesn't show the specifics. The newer one shows the specifics, but does not render the preview. It shows only a white rectangle..
My problem: i need both /:
-The control uses a QML SceneGraph c++ extension plugin for rendering. The older QtCreator has no problems with that...
-The module folder is located in <Qt>/gcc/qml/
-Compiling and running works fine with all permutations of Qts and Creators.
First thought: The newer QtCreator is based on Qt. 5.3.2 .. So I recompiled my extensions with that Qt version and made a module copy in the appropriate Qt folder. With no success..
So.. Does anybody has an idea what's going wrong here? Or did I encounter a regression?
Thank you very much in advance!
All the best,
Frime -
Hi,
can you check this option for Qt Quick Designer:
Always use the QML emulation layer provided by Qt CreatorTo run C++ plugins you have to make sure to use a qml2puppet build with the correct Qt version:
http://doc-snapshot.qt-project.org/qtcreator-3.3/creator-qml-modules-with-plugins.html -
Yep, it works now.
I unchecked "Always use the QML emulation layer provided by Qt Creator". After that, QtDesigner built a new and working qml2puppet layer. Thank you very much, again!
Greetings to Berlin,
Frime -
Yep, it works now.
I unchecked "Always use the QML emulation layer provided by Qt Creator". After that, QtDesigner built a new and working qml2puppet layer. Thank you very much, again!
Greetings to Berlin,
Frime