Qt World Summit: Register Today!

Editing QML Objects from C++ File

  • So I have a C++ program that has

    Q_PROPERTY( QList<QString> messages READ getMessages NOTIFY messagesChanged )


    Q_SIGNAL void messagesChanged(QString message)

    Every time I add a QString to the QList I send a signal using Q_EMIT messagesChanged(message) from a function called addMessages(QString message) which appends a QString to the QList. How can I use this signal to update a List object described in a QML file so that text will populate the List and appear on the screen each time something is added to the QList?

  • Hi,

    You can use connections in QML as onmessagesChanged: and you can update your list in QML display screen with target setting it as c++ file object which you have exposed to QML.

Log in to reply