How to add item to qml listview ? the model can't change !
-
Hi:
I am using qml now to develop a message app,I can get a message list model from certain lib ,the model can't change . Each message item in the model contains a time information ,a text ,a direction (in or out ), I use a listview to show it by assign the model to listview ,I make a delegate to show it .
show like this :
text 1
10:10:06text 2
10:10:17text 3
10:12:59text 4
15:22:23text 5
17:35:08But now I want to show time once for time close messages:
like below:10:10:06
text 1
text 2
text 3
15:22:23
text 4
15:35:08
text 5
message 1 2 3 are considered to be a conversation,because they talk in 1 hour ,so show 10:10:06 once at begin of message 1.
The problem is how to make the listview show like this ?
Thanks !! -
very emergency
-
Hi,
Have a look at this "example":http://qt-project.org/doc/qt-4.8/declarative-modelviews-listview-sections.html
-
I know you mean use the section property ,but my list item may like this
ListElement { text: "message 1"; time: "10:15:34" } ListElement { text: "message 2"; time: "10:15:56" } ListElement { text: "message 3"; time: "10:17:06" } ListElement { text: "message 4"; time: "13:34:12" } ListElement { text: "message 5"; time: "17:45:01" }
I want to make message time in one hour into one section ,thus message 1 2 3 in one section named 10:15:34 ,message 4 in one section named 13:34:12,message 5 in one section named 17:45:01 .How to implement it?
-
Ok, i think then you need to implement something like treeview as the text messages are actually the childs of time and whenever you get a new entry for time you will first need to check if it is present in the view, if not then add it and then add the text message as per the time by parsing the tree.
-
I don't how to subclass the qml listview ,is the qml listview the same with qt c++ listview
[quote author="p3c0" date="1382002504"]Ok, i think then you need to implement something like treeview as the text messages are actually the childs of time and whenever you get a new entry for time you will first need to check if it is present in the view, if not then add it and then add the text message as per the time by parsing the tree.[/quote] -
No what i'm trying to say is your view needs to be like a TreeView where the childs are grouped according to its repective parent.
Here Parent being the Time and Child being the Text.
But unfortunately Qt 5.1 or Qt 5.1 does not have TreeView yet. -
Is qml have any class that I can put item in have a vertical slide capacity
[quote author="p3c0" date="1382004958"]No what i'm trying to say is your view needs to be like a TreeView where the childs are grouped according to its repective parent.
Here Parent being the Time and Child being the Text.
But unfortunately Qt 5.1 or Qt 5.1 does not have TreeView yet. [/quote] -
Hi,
May be this "TreeView":http://qt-project.org/forums/viewthread/30521/ would help you. As according to "this":http://qt-project.org/forums/viewthread/33594/#146846 thread a TreeView can be achieved like this as of now. For vertical slide he has used ScrollView. I have not tried the code myself though.
-
I can't find treeview in qml ,you mean c++?
[quote author="p3c0" date="1382007121"]Hi,May be this "TreeView":http://qt-project.org/forums/viewthread/30521/ would help you. As according to "this":http://qt-project.org/forums/viewthread/33594/#146846 thread a TreeView can be achieved like this as of now. For vertical slide he has used ScrollView. I have not tried the code myself though. [/quote]
-
There's no TreeView in QML currently but there's a "workaround":http://qt-project.org/forums/viewthread/30521/#146845 for it. Did you see those links ?