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. How to reload the tableview to reload its data ?
Forum Updated to NodeBB v4.3 + New Features

How to reload the tableview to reload its data ?

Scheduled Pinned Locked Moved General and Desktop
4 Posts 3 Posters 10.9k Views 1 Watching
  • 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.
  • D Offline
    D Offline
    dhay06
    wrote on last edited by
    #1

    Hi i retrieve data from a data base with a model and then it is displayed with a tableview.
    i have a button witch delete the selected row from the tableview. When i click on it, the row is deleted from the database but no from the tableview. So witch function can i use to reload the data in the tableview?

    1 Reply Last reply
    0
    • I Offline
      I Offline
      ivan.todorovich
      wrote on last edited by
      #2

      If you are using QSqlQueryModel you should re-set its query using setQuery.
      There isn't any function to 'refresh' a QSqlQueryModel.

      o_o Sorry for my rusted english.

      1 Reply Last reply
      0
      • D Offline
        D Offline
        dhay06
        wrote on last edited by
        #3

        actually i use QSqlTableModel. To refresh the tableview i did @model->select();
        ui->tableView1->setModel(model);@ and it works thanks :)

        1 Reply Last reply
        0
        • G Offline
          G Offline
          goetz
          wrote on last edited by
          #4

          The call to select does the trick alone.

          Calling setModel() with the same model as before is a no-op anyways :-)

          @
          void QAbstractItemView::setModel(QAbstractItemModel *model)
          {
          Q_D(QAbstractItemView);
          if (model == d->model)
          return;
          @

          http://www.catb.org/~esr/faqs/smart-questions.html

          1 Reply Last reply
          0

          • Login

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