void documentation QAbstractScrollArea :: setViewportMargins (int left, int top, int right, int bottom) says:
Sets the margins around the scroll area to the left, top, right, and bottom. This is useful for applications such as spreadsheets with "locked" rows and columns. Marginal space remains empty; place widgets in an unused area. Note that QTreeView and QTableView often call this function, so fields must be implemented by subclasses of QAbstractScrollArea. In addition, if subclasses are to be used in element representations, they should not call this function.
First of all, I got confused in the description itself. The function is not virtual, so this is not the case when I have to re-implement it to provide my fields. If I will call it, than when, at what points? And if QTreeView calls it internally with its own values, then how will our calls work together? Looking at the sources of Qt, I found that QTreeView :: updateGeometries () calls it with parameters (essentially) 0, headerHeight, 0, 0. So should I reimplement updateGeometries ()?
Google then discovered that other people called setViewportMargins () from an overridden resizeEvent (). So I also did this, and this works BUT:
- I am wondering how this method coexists with the internal QTreeView :: updateGeometries (), which calls setViewportMargins () with substantially hardcoded parameters (only the Height header changes to 0 if the header is hidden)?
- Although it works, an "unused area" appears on the header. But to implement the "locked" lines mentioned in the documentation, you need this area under the heading
I have an unused area below the header, overriding updateGeometries () and moving the header () to the beginning (after calling QTreeView :: updateGeometries ();). But I'm not sure if this is correct.
So my question is: How to implement "locked" rows is understood by setViewportMargins () documentation and how should they be implemented?
Note that I know of another way to implement frozen rows (or columns) - An example of a frozen column . But this is not exactly what I need, because this technique hides the first row (column) of the main widget of the table (tree) and shows it in the overlay (static) widgets. In my case, I need other information in the area below the header, and the main widget should actually be moved down to show all the rows