Results 1 to 4 of 4

Thread: Passing QML component to C++ function

  1. #1
    Join Date
    Apr 2014
    Posts
    125
    Qt products
    Qt5 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Android Maemo/MeeGo

    Question Passing QML component to C++ function

    Hello

    http://doc.qt.io/qt-4.8/qml-component.html

    I have a Q_INVOKABLE C++ function which must receive one QML component as a parameter.
    What should be the parameter type of the C++ function?
    When inside the C++ function, how to access the individual properties of the QML component?

    Any example?

    Thanks;

    Mut

  2. #2
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Passing QML component to C++ function

    Do you mean a component or an object?

    I.e. is the QML side a Component or e.g. a QQuickItem type?

    Also: what do you need this for? Very often "accessing QML from C++" means there are better ways of achieving the same result

    Cheers,
    _

  3. #3
    Join Date
    Apr 2014
    Posts
    125
    Qt products
    Qt5 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Android Maemo/MeeGo

    Default Re: Passing QML component to C++ function

    Thanks for the reply.

    The QML side is a Component.
    I want to store the component or a pointer to it in my c++ class and later give it back to QML upon request.
    I also wondering what should be the signature of second function i.e. the one which allow QML side to get the component?

    Mut

  4. #4
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Passing QML component to C++ function

    The C++ class for the QML Component type is QQmlComponent.

    So a property of type QQmlComponent* should work.

    Cheers,
    _

Similar Threads

  1. Passing strings to SLOT function
    By ashboi in forum Qt Programming
    Replies: 23
    Last Post: 12th September 2013, 10:37
  2. Replies: 4
    Last Post: 2nd April 2010, 11:04
  3. Passing QsqlRecords in a function
    By ambarish_singh in forum Qt Programming
    Replies: 7
    Last Post: 13th August 2009, 12:10
  4. Replies: 3
    Last Post: 17th July 2008, 08:43
  5. Replies: 1
    Last Post: 28th May 2008, 17:52

Tags for this Thread

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.