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. Urgent pleeease - paging in a qtablewidget [SOLVED]

Urgent pleeease - paging in a qtablewidget [SOLVED]

Scheduled Pinned Locked Moved General and Desktop
6 Posts 3 Posters 5.0k 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
    Shimon
    wrote on last edited by
    #1

    Hi,

    I need to load a huge log file in my project, suppose 10^6 rows.
    If I don't use paging it gets too slow.
    So I must use paging, every page about 10^3 - 10^4 rows.

    How can I do it with QTableWidget?
    (In c# there is no problem with the datagridview - it has a property for enabling paging)
    I've googled but didn't found anything about it.

    Please help.
    Thank you very much

    1 Reply Last reply
    0
    • sierdzioS Offline
      sierdzioS Offline
      sierdzio
      Moderators
      wrote on last edited by
      #2

      I think you'll need to use MVC and QTableView. This will not be easy, though.

      (Z(:^

      1 Reply Last reply
      0
      • jazzycamelJ Offline
        jazzycamelJ Offline
        jazzycamel
        wrote on last edited by
        #3

        I concur with sierdzio, you're gonna need to subclass "QAbstractTableModel":http://qt-project.org/doc/qt-4.8/qabstracttablemodel.html and re-implement the "fetchMore":http://qt-project.org/doc/qt-4.8/qabstractitemmodel.html#fetchMore and "canFetchMore":http://qt-project.org/doc/qt-4.8/qabstractitemmodel.html#canFetchMore methods to get the data from the file in manageable chunks as the user navigates to it (from a "QTableView":http://qt-project.org/doc/qt-4.8/qtableview.html rather than QTableWidget).

        For the avoidance of doubt:

        1. All my code samples (C++ or Python) are tested before posting
        2. As of 23/03/20, my Python code is formatted to PEP-8 standards using black from the PSF (https://github.com/psf/black)
        1 Reply Last reply
        0
        • S Offline
          S Offline
          Shimon
          wrote on last edited by
          #4

          I don't have any idea what you mean - what's MVC, and how it can help with QTableView?
          Any code sample of adding 100 records and splitting it in real time into 10 pages for example?

          Isn't there anyone who encountered this need ever so he could supply a little more detailed way with code?

          Thank you very much though for the idea.

          1 Reply Last reply
          0
          • jazzycamelJ Offline
            jazzycamelJ Offline
            jazzycamel
            wrote on last edited by
            #5

            Ok, MVC stands for "Model View Controller":http://en.wikipedia.org/wiki/Model–view–controller, google would have answered that question for you (faster than posting here) as its a core design principle.

            Yes, many people have encountered this issue and thats why you were directed to the MVC solution, Qt is very good at this and there are many examples (all of which contain code) included with the framework. A good place to start would be to read "this":http://qt-project.org/doc/qt-4.8/model-view-programming.html primer and look at examples referenced at the bottom.

            For the avoidance of doubt:

            1. All my code samples (C++ or Python) are tested before posting
            2. As of 23/03/20, my Python code is formatted to PEP-8 standards using black from the PSF (https://github.com/psf/black)
            1 Reply Last reply
            0
            • S Offline
              S Offline
              Shimon
              wrote on last edited by
              #6

              OK - That's just a great link!!! Thank you very much dude :-)

              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