Originally Posted by
wysota
Reimplementing the view to create spacing shouldn't really be that hard. From what I remember visualRect() is the steering wheel for all geometry in the view so it should be sufficient to change only that one method.
Strangely the visualRect() did not do anything. I subclassed QTableView and reimplemented visiualRect(). It was never called. And when I call visiualRect() on QTableView, it always returns QRect(0,0,0x0).
But the problem is now even more solved than before. Though I really don't unterstand the problem. As I wrote, I change the row height in the rowsInserted slot.
I did something like this (pseudo-Qt code):
QTableView->setRowHeight(row,f.height()+x);
QTableView->setRowHeight(row2,f.height()+y);
....
QFontMetrics f(font())
QTableView->setRowHeight(row,f.height()+x);
QTableView->setRowHeight(row2,f.height()+y);
....
To copy to clipboard, switch view to plain text mode
Now this worked sometimes. When I sorted or changed the layout of table, the heights got messed up.
My solution, which seems to solve all the problems I had?
int fontheight = f.height();
QTableView->setRowHeight(row,fontheight+x);
QTableView->setRowHeight(row2,fontheight+y);
....
QFontMetrics f(font())
int fontheight = f.height();
QTableView->setRowHeight(row,fontheight+x);
QTableView->setRowHeight(row2,fontheight+y);
....
To copy to clipboard, switch view to plain text mode
Don't ask me why this solves the problem. Not the slightest idea. Nevertheless, it is cleaner code anyways.
Bookmarks