Results 1 to 10 of 10

Thread: calling QCoreApplication::processEvents(); wenn filling a model with data

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts

    Default Re: calling QCoreApplication::processEvents(); wenn filling a model with data

    Well, I am only guessing, but your current setup sounds like you are adding one row after another, most likely while the model is already shown in a view.
    Each add results in updates on the view, causes memory to be copied, items to be created, etc.

    A model that just interfaces with the data would just report the total number of rows to the view. The view would then get all data it currently needs.
    No need for copying large amounts of data or even accessing data currently not displayed.

    Cheers,
    _

  2. #2
    Join Date
    Jun 2012
    Posts
    38
    Qt products
    Qt4
    Platforms
    Unix/X11
    Thanks
    10
    Thanked 1 Time in 1 Post

    Default Re: calling QCoreApplication::processEvents(); wenn filling a model with data

    You are correct in your assumption. I do add the rows one by one, and the view is updated the whole time.

    but in this case I guess I wouldn't be able to do it any other way?. I am talking about a user adding 5000 or more titles to a play list. The model doesnt know yet what files the user will add so the data will have to be copied. - at least the first time they are added. the next time it could be retrieved from a database.

    How does other tools such as Itunes, banshee etc. deal with this kind of problem. I believe they will retrieve the data from the files, but not update the view until all rows are retrieved.

  3. #3
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts

    Default Re: calling QCoreApplication::processEvents(); wenn filling a model with data

    Even if the user adds files one by one (not likely), in the case of a model that is merely an interface to the data, it doesn't have to copy the data that is currently not needed by the view.

    In the more likely case that a users selects lists of files, e.g. whole directories or even directory trees, a model can expose all new rows in one go, or in chunks, etc.

    Cheers,
    _

  4. #4
    Join Date
    Jun 2012
    Posts
    38
    Qt products
    Qt4
    Platforms
    Unix/X11
    Thanks
    10
    Thanked 1 Time in 1 Post

    Default Re: calling QCoreApplication::processEvents(); wenn filling a model with data

    In the more likely case that a users selects lists of files, e.g. whole directories or even directory trees, a model can expose all new rows in one go, or in chunks, etc.
    I might have a wrong idea here. Please be patient with me :-)

    so you idea is to just add chunks of let say 100 rows at the time?

    is there away to do that? wont I still have to add the rows one by one to the model?

    -Remember it is likely the model has data already, I dont want to loose this data.

  5. #5
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts

    Default Re: calling QCoreApplication::processEvents(); wenn filling a model with data

    Exposing more rows in chunks is one option, e.g. if doing all the data in one go would leave the UI empty for too long.

    A model can expose any number of rows anywhere in its range at any time, see QAbstractItemModel::beginInsertRows().

    Cheers,
    _

Similar Threads

  1. Replies: 2
    Last Post: 23rd June 2014, 14:37
  2. Replies: 0
    Last Post: 14th April 2011, 16:10
  3. QTreeView + own model + dynamic filling
    By Urvin in forum Newbie
    Replies: 7
    Last Post: 19th February 2010, 18:11
  4. Replies: 4
    Last Post: 20th February 2007, 13:35

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
  •  
Qt is a trademark of The Qt Company.