Draw separator between overlapping QTableviews
-
Hello,
my class is derived from QTableview and is based on the "frozentableview"-example from https://doc.qt.io/qt-5/qtwidgets-itemviews-frozencolumn-example.html. But my version is a bit more complex (I can have frozen columns OR rows) and a there can bemultiple frozen rows/columns and not only 1.
My question:
I need an optical separator between the "frozen" part of the table and the normal table. it should be a line with a width of 5 pixel and it should be only visible in the sheet itself (not in the headers). Sorry difficult to describe...Has someone an idea what would be an easy solution for that?
One idea is, that I just draw, after everything else is painted, the line from the QWidget which is the parent of them. But than I need to calculate the exact position of the start/end of the frozen table and after a resize have I have to recalculate it everytime and so on...
Thank you!
-
a lazy way would be to make a overlay qframe line with 5 pixel thickness on top of tableview in void showEvent(QShowEvent *);
Its location can be found easily.
A better way would be to draw bottom or top border lines of all items in that row by overriding the paint event. -
@JoeCFD I tried already your second suggestion.
My problem, was that I am not able to paint on the middle of the grid, because the frozen view lays on top of the "normal" view and if I repaint the normal view border, one half of the border is hidden by the frozen view. and if i try that with the frozen view I can only paint one half of the Line because i cant paint over the borders of the Widget.
-
@JoeCFD I like the idea with the QFrame but I am not realy sure how to do that..
https://doc.qt.io/qt-5/qframe.html I guess I would need the VLine version right? because I only need the separator on one side. But how would I determine which side?
-
Hi,
Just a wild guess but what about keeping the border in the stylesheet but fix them all to 0 except the one you want with 5px ?
-
What result did you get from my suggestion ?