Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Consequences for calling beginInsertRows() and endInsertRosw() an once?
Forum Updated to NodeBB v4.3 + New Features

Consequences for calling beginInsertRows() and endInsertRosw() an once?

Scheduled Pinned Locked Moved Unsolved General and Desktop
2 Posts 2 Posters 264 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • W Offline
    W Offline
    WCompton
    wrote on last edited by
    #1

    Hey all,
    I asked this question on stack overflow sometime ago but did not get and answer:

    [https://stackoverflow.com/q/70962488/10231906](link url)

    The Qt documanetation is very clear that you should sandwich your data changes between beginInsertRows()/endInsertRows() or beginResetModel()/endResetModel() etc. My issue here is that I'm having to significantly compromise the simplicity of the design to accomodate this requirement. Are there really serious negative consequence for doing this:

    change_data();
    beginInsertRows();
    endInsertRows();
    

    instead of this:

    beginInsertRows();
    change_data();
    endInsertRows();
    

    I have tried the latter before and everything compiled and ran just fine. Just trying to get a sence for how crucial this really is. Thanks for your help.

    1 Reply Last reply
    0
    • Christian EhrlicherC Online
      Christian EhrlicherC Online
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on last edited by Christian Ehrlicher
      #2

      Your first code will most likely kill your view sooner or later, esp. when you have selections, item widgets and insert somewhere in between since beginInsertRows() expects that the model contains the old row count and endInsertRows() sees the new row count in the model.

      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
      Visit the Qt Academy at https://academy.qt.io/catalog

      1 Reply Last reply
      2

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved