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. [Solved] QTableView and QSqlQueryModel: Change number of rows first loaded from model.
Forum Updated to NodeBB v4.3 + New Features

[Solved] QTableView and QSqlQueryModel: Change number of rows first loaded from model.

Scheduled Pinned Locked Moved General and Desktop
3 Posts 2 Posters 1.4k 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.
  • A Offline
    A Offline
    asjafjell
    wrote on last edited by
    #1

    I am currently creating a tool to preview data from SQL database tables. I have QTableView that shows the data, and run-time I connect a QSqlQueryModel based on user click in a list of table names. The data is fetched from a SQLite database.

    Simplified, this is how i populate the view:

    @
    QString query = query = "SELECT * FROM " % ui.lswPreviewTables->currentItem()->text();
    QSqlQueryModel currentDataModel->setQuery(query, currentDatabase);
    tableView->setModel(currentDataModel);
    tableView->show();
    @

    My quyestion is: Is there a way to reduce the number of rows initially loaded? I have read somewhere in the forums that this is 255 or 256 rows. For a click-and-hold function for preview, the loading is a bit too slow when columns exceeds 70.

    Thanks in advance.

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi and welcome to devnet,

      Depending on your needs, you could simply add a LIMIT to your query

      Hope it helps

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • A Offline
        A Offline
        asjafjell
        wrote on last edited by
        #3

        That was really clever, SGaist. I don't know why that did not cross my mind. I want the user to be able to scroll the QTableView to see more data. Maybe a solution is to remove LIMIT from the model's query as soon as the scrollbar value changes.

        Thank you for your help.

        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