Results 1 to 2 of 2

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

Hybrid View

Previous Post Previous Post   Next Post Next Post
  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'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
    May 2009
    Location
    Canada
    Posts
    163
    Thanks
    7
    Thanked 20 Times in 20 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Windows Android

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

    Hm, well, presuming you have a SOURCE of dynamic data, you can use that data to populate a model, then expose that model to a QML view. See this tutorial for more...it's a bit dated, and QDeclarativeItem may not be your poison, but it is very helpful for wrapping your head around the basic, step-wise concepts.

Similar Threads

  1. Replies: 0
    Last Post: 29th March 2012, 19:56
  2. How should I create a view with dynamic fields?
    By ls4f in forum Qt Programming
    Replies: 10
    Last Post: 22nd December 2011, 16:36
  3. Replies: 1
    Last Post: 20th January 2011, 17:17
  4. Replies: 2
    Last Post: 16th May 2010, 16:15
  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
  •  
Qt is a trademark of The Qt Company.