Results 1 to 2 of 2

Thread: Create dynamic QML components from within C++! How to?

  1. #1
    Join Date
    Jun 2010
    Posts
    31
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Create dynamic QML components from within C++! How to?

    Hi all,

    I have posted that thread also to QtQuick Forum but maybe somebody else here can help me.

    I'm using Qt over some years but without QML. Now I want to add the flicker functionality to my applications UI.
    The application logic itself is coded in C++ (inherited sockets, database classes e.g.).

    My applications UI should be fully configureable for diffrent customers, what means:

    Customer 1: wants to have 5 sliding pages
    Customer 2: wants to have 7 sliding pages

    and so on. The number of pages should be loaded by a custom xml config file in the C++ part of application.

    The first trips into QML examples were successfully. The example ..\4.8.2\examples\tutorials\gettingStarted\gsQml\p arts\part2 makes exactly what I want. Yeahh!

    My question here:
    How I can create/adding QML elements dynamically from C++ and insert it into the QML UI?

    I'm confused about that statements in the QML documentation, chapter "Dynamic Object Management in QML":

    "QML provides a number of ways to dynamically create and manage QML objects. The Loader, Repeater, ListView, GridView and PathView elements all support dynamic object management. Objects can also be created and managed from C++, and this is the preferred method for hybrid QML/C++ applications (see Using QML Bindings in C++ Applications)."

    And then you can read this here in "Using QML Bindings in C++ Applications":

    "Warning: While it is possible to use C++ to access and manipulate QML objects deep into the object tree, we recommend that you do not take this approach outside of application testing and prototyping. One strength of QML and C++ integration is the ability to implement the QML user interface separately from the C++ logic and dataset backend, and this strategy breaks if the C++ side reaches deep into the QML components to manipulate them directly."

    What next?

    The QML examples uses always a fixed, known, predefined QML UI.

    Can anybody make a suggestion or help me?

    Thanks

  2. #2
    Join Date
    Jan 2012
    Location
    Iran, Tehran
    Posts
    308
    Thanks
    75
    Thanked 24 Times in 21 Posts
    Qt products
    Qt4 Qt5 PyQt3 PyQt4
    Platforms
    Unix/X11 Windows

    Default Re: Create dynamic QML components from within C++! How to?

    You can call a qml function in c++ to create a dynamic element. All of data that is required by this element can send by c++ as QVariantArray to qml

Similar Threads

  1. Replies: 1
    Last Post: 20th October 2012, 11:47
  2. Replies: 0
    Last Post: 29th March 2012, 19:56
  3. How should I create a view with dynamic fields?
    By ls4f in forum Qt Programming
    Replies: 10
    Last Post: 22nd December 2011, 16:36
  4. Replies: 1
    Last Post: 20th January 2011, 17:17
  5. ui components
    By addu in forum Qt Programming
    Replies: 0
    Last Post: 17th September 2009, 14:49

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.