Search code examples
c++qtqscrollareaqsplitter

Find size of QScrollArea widget when scrollbar disappears


I have the following Qt widget layout

QSplitter
  QFrame (select area), a QTableView
  QScrollArea (data area)
     QWidget (entry and edit form)

The user might prefer to see more of the select area, that's why the "data area" is in a scroll area. I can adjust the size of the "select" and "data area" by the vertical splitter. All fine.

Now I want to implement a convenience feature (keyboard shortcut) so that the "data area" extends / resizes to the (exact) size where no scrollbar is needed. But how can I obtain that height? I could increment height until the scrollbar disappears, but this is stupid.

I do not want the "data area" consuming too much space, but just as it requires to be displayed without scrollbar.


Solution

  • Yes, if I take the inner widget ("entry...") and add some offset (for the QSCrollArea) on top of it seems to work reasonably.