Results 1 to 2 of 2

Thread: Updating data model for QML while already displaying view

  1. #1
    Join Date
    Jul 2012
    Posts
    4
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Updating data model for QML while already displaying view

    Hi,

    I have a Qt project with QML ui interface designed to display information coming in about vehicle status. I use a carData object to store the information about the car. Right now, it is implemented like this:
    Qt Code:
    1. int main(int argc, char *argv[])
    2. {
    3. QApplication a(argc, argv);
    4. MainWindow w;
    5. carData *data = new carData();
    6. w.rootContext()->setContextProperty("data", data);
    7. w.show();
    8. return a.exec();
    9. }
    To copy to clipboard, switch view to plain text mode 

    However, information on car status is obviously constantly changing, so I want to update the carData object every second or so to reflect the most current data on the car. I can write an update method that will reset the contents of the carData object, but I am wondering how I will be able to do this once w.show() or a.exec() has been called. How can I continuosuly update the object being displayed while the display is already running? Would it work to do something along the lines of:
    Qt Code:
    1. while(true) {
    2. data->update();
    3. w.show();
    4. }
    To copy to clipboard, switch view to plain text mode 

  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: Updating data model for QML while already displaying view

    You need to properly implement your model based on QAbstractItemModel.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


Similar Threads

  1. model/view json data displaying
    By binaural in forum Qt Programming
    Replies: 5
    Last Post: 27th June 2012, 09:13
  2. Replies: 1
    Last Post: 24th February 2011, 06:54
  3. Replies: 7
    Last Post: 22nd November 2009, 20:47
  4. Replies: 1
    Last Post: 14th January 2009, 11:10
  5. Table Model / View Problem -- Data Not Displaying
    By jhendersen in forum Qt Programming
    Replies: 1
    Last Post: 22nd April 2007, 07:45

Tags for this Thread

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.