PDA

View Full Version : Filling QtableView/QListView with RealTime data



gyre
24th September 2007, 18:40
Hi all!
I'm developing an app that listen on file descriptor using QSocketNotifier.
I need it to display new data that arrives on that FD in QTableView/QListView real-timeingly
What I mean is this:
Data arrives - put it in the first line, another data arrives put it in the second line and so on...

What is the best way to do it ?
Are there any examples on net where I could take an insipration ?

THanks a lot !

wysota
24th September 2007, 20:27
Well... there isn't much to think about. Simply connect notifier's signal to a custom slot and add the data to the model from within the slot.

gyre
24th September 2007, 20:39
I just wanted to be sure if there is no need somehow to "update" View when new data are added...It shoul look like "watching the log"...

And another question...
I'm thinking about using the QTableView...
Data are actually messages with ID and things like that...Message that will arrive will be added into rows - each message will be added on a row - each piece of message in its dedicated column of that row.
So when I want now to sort the messages according to let's say ID how can I do that ?
I mean when I want them to be sorted by ID , I want the whole rows to be sorted...not only the items in "ID" column...

I want it to look like when you sort your messages in your mail client...sort by date, time, person...

THanks a lot for any help!

wysota
24th September 2007, 22:00
The concept of the view assures that it updates itself when the data changes.

I suggest you first implement adding data and then think about sorting (it's trivial, you'll probably simply need to activate the sorting property of the table view).

gyre
25th September 2007, 17:28
Thanks I'll try that...
But I'll be able to do that if you answer me probably the last question I'm gonna ask you :)
Data I want to display in QTableView are beeing stored to QList when they arrive...
But...How can I take them out of the QList and put them in a Model ?
Data in QList are a special custom structure...

What class should I use and how...I didn't find any examples on doc.troll* to do that..
There is a lot of examples showing how to add StandardItem to StandardItemModel and so on...but no example for custom data...

THanks :)

ps: I promise...this is te last question :)

wysota
25th September 2007, 19:38
Data I want to display in QTableView are beeing stored to QList when they arrive...
But...How can I take them out of the QList and put them in a Model ?
Data in QList are a special custom structure...
Maybe you should store it directly in the model instead of the QList? There is no need for two interfaces to the same data set. Model is just an interface to data and you can use it with or without a view.


What class should I use and how...I didn't find any examples on doc.troll* to do that..
There is a lot of examples showing how to add StandardItem to StandardItemModel and so on...but no example for custom data...

Depends how custom your structure is. The best solution would be to build a custom model for your structure (around your QList) but it requires a bit of work if you haven't done that before (and I assume that is the case). You can take a look at my articles about building models either at our wiki or on my blog.


ps: I promise...this is te last question :)
You can ask as many questions as you want. That's what the forum is for.