Results 1 to 4 of 4

Thread: Passing QQuickGradient, QQmlComponent and LabelStyle values from QML to C++;

  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 QQuickGradient, QQmlComponent and LabelStyle values from QML to C++;

    Hello;

    QML side: can I pass (by value) QQuickGradient, QQmlComponent and LabelStyle from QML to C++ as QVariant type?
    C++ side: can I store them in say a QVarianMap?
    QML side: can I then retrieve (from C++) the store values as QVariant?

    void myClass::set(const QVariant& value, const QString& name) { // QINVOKABLE method called from QML side
    {
    // insert in QVariant map with name as a key
    }

    QVariant myClass::get(const QString& name) { // QINVOKABLE method called from QML side

    // retrieved from the QVariant map
    }

    Any thoughts?

    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 QQuickGradient, QQmlComponent and LabelStyle values from QML to C++;

    QQmlComponent exists as a public type, but all of them are QObject derived, so a QObject* should do.

    Obviously keep in mind that these pointers are owned by the QQmlEngine which can delete them at any given time.

    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 QQuickGradient, QQmlComponent and LabelStyle values from QML to C++;

    Thank you for the reply.
    Do you mean that my parameter can be pointer to QObject (QObject*) instead of QVariant?

  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 QQuickGradient, QQmlComponent and LabelStyle values from QML to C++;

    Yes

    Cheers,
    _

Similar Threads

  1. Replies: 2
    Last Post: 21st February 2013, 06:05
  2. passing values in qml
    By vinayaka in forum Newbie
    Replies: 0
    Last Post: 20th July 2011, 13:36
  3. Passing QTableWidget values to another QWizard page
    By slava in forum Qt Programming
    Replies: 2
    Last Post: 1st July 2010, 13:42
  4. Passing values to custom 'slot' functions (pyqt)
    By Richie in forum Qt Programming
    Replies: 2
    Last Post: 7th September 2009, 07:05
  5. Passing Command Line Values?
    By Kapil in forum Newbie
    Replies: 1
    Last Post: 29th March 2006, 08:26

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.