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. QTableView & QSqlQueryModel :when query changes
QtWS25 Last Chance

QTableView & QSqlQueryModel :when query changes

Scheduled Pinned Locked Moved General and Desktop
5 Posts 3 Posters 3.1k 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.
  • S Offline
    S Offline
    soleverlee
    wrote on last edited by
    #1

    there is a QTableView to display query results, and I set it's model as a QSqlQueryModel:
    @
    QSqlQueryModel* sqlModel = new QSqlQueryModel();
    sqlModel->setQuery(“SELECT id,title FROM tbarticle where key = '1'”, db);
    tableView->setModel(sqlModel) ...
    @
    Now I'd like to query key = '2',and show them on the same tableView, what should I do?
    Should I reset the model of the tableview,or change it?

    Another question, if I insert into the database, how should I update the view?
    Looking forward to your ideas!

    Edit: Please use @ tags around code sections; Andre

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

      to your first question: call setQuery() with the new query.

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

      1 Reply Last reply
      0
      • S Offline
        S Offline
        soleverlee
        wrote on last edited by
        #3

        Thank u

        1 Reply Last reply
        0
        • A Offline
          A Offline
          andre
          wrote on last edited by
          #4

          To your second question: call setQuery() with the old query.

          ;-)

          1 Reply Last reply
          0
          • S Offline
            S Offline
            soleverlee
            wrote on last edited by
            #5

            nice. Thank u very much

            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