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. Updating Scrollbar QTableView when model shrink
QtWS25 Last Chance

Updating Scrollbar QTableView when model shrink

Scheduled Pinned Locked Moved General and Desktop
7 Posts 3 Posters 1.9k 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.
  • M Offline
    M Offline
    Misty River
    wrote on last edited by
    #1

    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
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      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
      0
      • SGaistS SGaist

        Hi,

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

        M Offline
        M Offline
        Misty River
        wrote on last edited by
        #3

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

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

          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
          0
          • A 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 Offline
            M Offline
            Misty River
            wrote on last edited by
            #5

            @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
            0
            • A 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 Offline
              M Offline
              Misty River
              wrote on last edited by
              #6

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

              1 Reply Last reply
              0
              • A Offline
                A Offline
                alex_malyu
                wrote on last edited by alex_malyu
                #7

                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
                0

                • Login

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • Users
                • Groups
                • Search
                • Get Qt Extensions
                • Unsolved