Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. QML Listview with C++ Model

QML Listview with C++ Model

Scheduled Pinned Locked Moved QML and Qt Quick
1 Posts 1 Posters 899 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    messi
    wrote on last edited by
    #1

    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

    1 Reply Last reply
    0

    • Login

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt Extensions
    • Unsolved