Results 1 to 6 of 6

Thread: Adding New Components to QML Designer

  1. #1
    Join Date
    May 2011
    Posts
    11
    Thanked 1 Time in 1 Post
    Qt products
    Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Adding New Components to QML Designer

    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.
    Qt Code:
    1. 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.
    Qt Code:
    1. 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
    Qt Code:
    1. 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:
    Qt Code:
    1. plugin mybuttonplugin
    To copy to clipboard, switch view to plain text mode 
    3.) Import your plugin in your main.qml
    Qt Code:
    1. 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"
    Qt Code:
    1. 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

  2. #2
    Join Date
    May 2011
    Posts
    11
    Thanked 1 Time in 1 Post
    Qt products
    Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Adding New Components to QML Designer

    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.
    Wow.Today I found the solution. I think. By searching for something different......that's life.

    Solution:
    Ideally, QML modules have a plugins.qmltypes file in the same directory as the qmldir file. The qmltypes file contains a description of the components exported by the module's plugins and is loaded by Qt Creator when the module is imported.
    Using QML Modules defined with C++ as Plugin

  3. #3
    Join Date
    Jun 2012
    Posts
    18
    Thanked 9 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Adding New Components to QML Designer

    How did you get this to work?

    Did you create your plugins.qmltypes file by hand?

    I copied my qml files to a "custom" folder into QT_PATH/imports/Qt/labs, but the qml components don't show up in the designer.

    Thanks

  4. #4
    Join Date
    Nov 2010
    Posts
    82
    Thanked 9 Times in 9 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Adding New Components to QML Designer

    the question you have to answer first withthis tutorial is how do you want to include your custom control in your application ?
    dll ? ressource ? plain qml files ?

  5. #5
    Join Date
    Jun 2012
    Posts
    18
    Thanked 9 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Adding New Components to QML Designer

    the question you have to answer first withthis tutorial is how do you want to include your custom control in your application ?
    dll ? ressource ? plain qml files ?

    I'm just talking about plain old QML files here. I want to copy my files into the QT_PATH/imports/ along with a qmldir file and then when I create a new QML file in the IDE I want to be able to import my files like:

    import components 1.0

    When I click design mode I'd like the controls to show up in the library/items pane so I can drag the control onto the canvas.

    It seems to me that this can not be don. I will have to either tweak the QTCreator code for this to happen, or I will have to some how convert my QML controls to c++ controls.

  6. #6
    Join Date
    Nov 2010
    Posts
    82
    Thanked 9 Times in 9 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Adding New Components to QML Designer

    are you in a qmlproject or qmlApplication ?


    Added after 13 minutes:


    no need for qmldir if it s plain qml just put
    import "/Qt/4.8.1/imports/Qt/custom" in your qml file
    save
    go to designer
    Last edited by Le_B; 2nd July 2012 at 13:36.

Similar Threads

  1. Replies: 2
    Last Post: 16th May 2010, 16:15
  2. Adding widgets in Designer
    By franco.amato in forum Newbie
    Replies: 3
    Last Post: 21st December 2009, 13:43
  3. StyleSheet components using Qt designer
    By Kostanev in forum Qt Tools
    Replies: 1
    Last Post: 21st April 2008, 08:28
  4. Adding scrollbars from within Designer
    By MrGarbage in forum Qt Tools
    Replies: 1
    Last Post: 3rd September 2007, 19:35
  5. Adding slots in Designer
    By jamos in forum Qt Tools
    Replies: 5
    Last Post: 18th May 2006, 23:28

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.