Hey,
I have a QTableWidget, whose row-height I prefer to be as compact as possible without compromising the readability of the text-cell-content.
To achieve this I call
Qt Code:
To copy to clipboard, switch view to plain text mode
Works perfect, but turns out to be very slow with larger models, to the point where I am looking at a blacked out window for seconds.
That makes sense, bc it has to look at fonts and styles etc and determine the height of many rows.
I have looked through the code and found the "setResizeContentsPrecision" method, however, even with very low values it isnt much of an improvement.
I *could* just do setSectionResizeMode(QHeaderView::Fixed) and then hardcode my preferred height.
But that would probably destroy UX across platforms, because this is really style and font dependent.
So the quest is to find a good, compact height. If I do setSectionResizeMode(QHeaderView::Fixed) and specify a height manually:
1. leaving the default the row-height is absurdly large, leaving tons of empty space.
2. if I use QFontMetric(font).lineheight() or QFontMetric(font).lineSpacing() then the height is too compact - it cuts off the lower pixels of a "p" or "q" or "g", for example. That makes the contents hard to read.
3. setDefaultSectionSize(QFontMetrics(table->font()).boundingRect("WIqgppÄ").height()); has the same problem - see this image for how it cuts off the last pixel(s) from "g":
https://i.imgur.com/KMpLZWV.png
i am on Qt 5.12 and Ubuntu18.04, but it's a cross platform app.
Sorry if this question isnt specific enough...
Bookmarks