Discussion Board

Results 1 to 2 of 2

Thread: Qml to C++

  1. #1
    Registered User
    Join Date
    Aug 2009

    Qml to C++

    I have a class defined in C++ called RssItem and exposed to QML with
    qmlRegisterType<RssItem>(...). In Qml I am accessing an XmlListModel and
    inside the delegate I am creating a RssItem object for each item in the
    model that is displayed in a listview in qml. At some point when clicking
    on the item in list, I take the RssItem object and pass it back to C++. I
    was assuming that it is passed as a RssItem * but I get a segmentation
    fault. What am I missing?
    So the question is : C++ objects created in Qml are passed to C++ slots
    in what manner? How can they be accessed in C++. I am pretty sure I get a
    pointer in my Slot but it is not to RssItem.


  2. #2
    Registered User
    Join Date
    Aug 2009

    Re: Qml to C++

    And the answer is, as Christian Kamm pointed on a Qt mail list, you actually don't get a pointer to RssItem but a Script value:

    void DownloadManager::addDownload(const QString &path, const QScriptValue & rssItemSV)
    RssItem * rssItem = qobject_cast<RssItem*>(rssItemSV.toQObject());

Similar Threads

  1. Drawing in QML
    By JeffC55 in forum [Archived] Qt Quick
    Replies: 8
    Last Post: 2011-04-27, 18:22
  2. Nokia Qt Sdk 1 RC 1 - No QML Support
    By cristids in forum [Archived] Qt SDKs and Tools
    Replies: 2
    Last Post: 2010-06-11, 12:31
  3. QML external JS file not found
    By anothertest in forum Qt
    Replies: 1
    Last Post: 2010-04-13, 11:33

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts