QML Listview with C++ Model



  • Hi everybody

    At the moment I'm writing a small messenger app.
    It's a simple app which contains of the following UI elements

    • ListView
    • TextInput
    • Send Button

    The C++ model is based on QAbstractListModel

    Everytime a user enters a text in the input field and press send it appears via the C++ model in the ListView.

    Now I would like to have the following behavior:
    The newest message shall appear at the bottom of the listview and the previous element shall move up.

    According to the doc I set "verticalLayoutDirection":http://http://qt-project.org/doc/qt-5.1/qtquick/qml-qtquick2-listview.html#verticalLayoutDirection-prop to ListView.BottomToTop.

    In my QAbstractListModel I have a simple QStringList member where I add my elements with
    "push_front(const T & value)":http://qt-project.org/doc/qt-5.1/qtcore/qlist.html#push_front

    Now I have the following problem. The listview show the element from BottomUp but the newest element will be added on the top of the previous and not below.
    The same behavior can be found in skype where you can see the newest message near the inputfield.

    Any ideas?
    Thanks for the help.

    Best regards
    Juergen


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.