Hello,
I want to add new Components to my QML Designer in my Qt Creator.
I have found 3 ways to do it:
Project specific:
1.) Create one Component "MyButton.qml" in a subfolder called "custom" inside of your QML-Project.
2.) Create qmldir-file in subfolder "custom" to populate your component.
MyButton 1.0 MyButton.qml
MyButton 1.0 MyButton.qml
To copy to clipboard, switch view to plain text mode
3.) Import your component in your main.qml inside of your QML-Project.
import "custom"
import "custom"
To copy to clipboard, switch view to plain text mode
Install QML-Component:
1.) Copy your "custom" folder into QT_PATH/imports/Qt/labs
2.) Import your component in your main.qml
import Qt.labs.custom 1.0
import Qt.labs.custom 1.0
To copy to clipboard, switch view to plain text mode
3.) Write an QML-Designer Plugin with a *.metainfo-File, where you populate your Component.
Install QML-Component in CPP:
1.) Write a simple Plugin, where MyButton inherits QDeclarativeItem.
2.) Copy your Plugin with your qmldir-File into QT_PATH/imports/Qt/labs
qmldir-file:
plugin mybuttonplugin
plugin mybuttonplugin
To copy to clipboard, switch view to plain text mode
3.) Import your plugin in your main.qml
import Qt.labs.custom 1.0
import Qt.labs.custom 1.0
To copy to clipboard, switch view to plain text mode
4.) Write an QML-Designer Plugin with a *.metainfo-File, where you populate your Component.
First Problem:
If I import in an installed-component ("Project specific", "Install QML-Component") a self constructed plugin, for example inside of "MyButton.qml"
import Qt.labs.plugins.mybuttondata 1.0
import Qt.labs.plugins.mybuttondata 1.0
To copy to clipboard, switch view to plain text mode
there will be no preview of "MyButton" inside of the QML Designer.
Second Problem:
If I create my grafical Item "MyButton" by a plugin ("Install QML-Component in CPP"), there will be no preview of "MyButton" inside of the QML-Designer.
Where is my mistake? What else do I have to do?
Thanks for any advice,
Greatz
Bookmarks