Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Urgent pleeease - paging in a qtablewidget [SOLVED]

    General and Desktop
    3
    6
    4591
    Loading More Posts
    • 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
      Shimon last edited by

      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 Reply Quote 0
      • sierdzio
        sierdzio Moderators last edited by

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

        (Z(:^

        1 Reply Last reply Reply Quote 0
        • jazzycamel
          jazzycamel last edited by

          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 Reply Quote 0
          • S
            Shimon last edited by

            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 Reply Quote 0
            • jazzycamel
              jazzycamel last edited by

              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 Reply Quote 0
              • S
                Shimon last edited by

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

                1 Reply Last reply Reply Quote 0
                • First post
                  Last post