Qt Forum

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

    Update: Forum Guidelines & Code of Conduct

    Updating Scrollbar QTableView when model shrink

    General and Desktop
    3
    7
    1487
    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.
    • M
      Misty River last edited by

      Hello,

      I have a model that dynamically shrinks and grows depending on user inputs and it is display in a tableview... the problem I'm having is that the scrollbars are never updated... they are set to the size of the data when I call setModel().. but when the model shrinks I can still scroll past the new smaller data... I've tried calling reset() and update() on the tableview but it has no effect on the scrollbar... How can I update the scrollbar so that it doesn't go past the size of the data??

      1 Reply Last reply Reply Quote 0
      • SGaist
        SGaist Lifetime Qt Champion last edited by

        Hi,

        Sounds like a glitch, what version of Qt are you using ? On which platform ?

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

        M 1 Reply Last reply Reply Quote 0
        • M
          Misty River @SGaist last edited by

          @SGaist I'm using the latest version of Qt on windows 10

          1 Reply Last reply Reply Quote 0
          • A
            alex_malyu last edited by alex_malyu

            If you are using custom model, it mostly likely a sign that model does not call appropriate required functions which are used for notification about data changes.

            M 2 Replies Last reply Reply Quote 0
            • M
              Misty River @alex_malyu last edited by

              @alex_malyu Yes, it is a custom model... and you are right I do not call any function when I change the data... I simply have a setter function that sets the model data... how should I go about changing the data??

              1 Reply Last reply Reply Quote 0
              • M
                Misty River @alex_malyu last edited by

                @alex_malyu The custom model derives from QAbstractTableModel btw...

                1 Reply Last reply Reply Quote 0
                • A
                  alex_malyu last edited by alex_malyu

                  look at:
                  https://doc.qt.io/archives/4.6/model-view-creating-models.html
                  and
                  http://doc.qt.io/qt-5/qabstractitemmodel.html

                  functions of interest typically start with begin...., end...
                  like:
                  void beginInsertRows(const QModelIndex & parent, int first, int last)
                  void beginRemoveRows(const QModelIndex & parent, int first, int last)
                  void beginResetModel()
                  ....

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