Learn what Felgo offers to help your business succeed. Start your free evaluation today! Felgo for Your Business


OverviewFelgo 3 Support (Qt 5) › including messenger backend into QML code


Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
  • #18766

    Felgo User

    <div class=”content”>

    Hello Guys,

    maybe i get here a solution of my problem.

    <div class=”content”>

    i´ve tried to put my own backend c++ code in a QML model, it´s from the v-play messenger example.
    i write a new class with this code:

    class DataObject : public QObject
        Q_PROPERTY(QString text READ text WRITE setText NOTIFY textChanged)
        Q_PROPERTY(QString detailText READ detailText WRITE setDetailText NOTIFY detailTextChanged)

    i add then with:
    QList dataList;
    dataList.append(new DataObject(chat->kon[i]->getname(), QVariant(ia).toString()));

    a new QList.

    so far so good.
    Now i add in the main.cpp with:

    engine.rootContext()->setContextProperty(“modelContact”, QVariant::fromValue(cont->dataList));

    a modelContact property.

    so in the example code it´s in the qml code the following area that i want to change:

    // Model should be loaded from your messaging backend
            //  model: [
            //    { text: "Tom McEloy", detailText: "Sorry for the late reply ...", image: Qt.resolvedUrl("../../assets/portrait0.jpg") },
            //    { text: "Leah Douglas", detailText: "Hahaha :D", image: Qt.resolvedUrl("../../assets/portrait1.jpg") }
            //  ]

    so like the comment i want to load the model from the backend, so i try:

    model: modelContact

    but i get no text or detailtext, where is the problem?



    Felgo Team


    are you using the SimpleRow type for showing your list entries?

    The SimpleRow only supports auto-detection of properties like text, detailText, etc… for array-based models (as in the QML example).
    For other list models, you can manually set the properties of the SimpleRow delegate to some properties of your model.

    See Models and Views with Qt Quick for more information on working with model/delegates in QML.


Viewing 2 posts - 1 through 2 (of 2 total)

RSS feed for this thread

You must be logged in to reply to this topic.

Qt_Technology_Partner_RGB_475 Qt_Service_Partner_RGB_475_padded