Results 1 to 6 of 6

Thread: Filling QtableView/QListView with RealTime data

  1. #1
    Join Date
    Sep 2007
    Posts
    99
    Thanks
    8
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Red face Filling QtableView/QListView with RealTime data

    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 !

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Filling QtableView/QListView with RealTime data

    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.

  3. #3
    Join Date
    Sep 2007
    Posts
    99
    Thanks
    8
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Red face Re: Filling QtableView/QListView with RealTime data

    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!

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Filling QtableView/QListView with RealTime data

    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).

  5. #5
    Join Date
    Sep 2007
    Posts
    99
    Thanks
    8
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Red face Re: Filling QtableView/QListView with RealTime data

    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

  6. #6
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Filling QtableView/QListView with RealTime data

    Quote Originally Posted by gyre View Post
    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.

Similar Threads

  1. speed of setdata - lots of items in treeview
    By Big Duck in forum Qt Programming
    Replies: 4
    Last Post: 6th July 2006, 13:53

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.