0

For a reason I have not yet realized, the out-of-the-box QTableView has row height about twice as large as QTreeView or QListView, at least on my system. I'm trying to figure out the default value Qt is supposed to have for this element type; sadly, the following code gets its second Q_ASSERT triggered.

QStyle *style = QApplication::style();
Q_ASSERT(style);
QStyleOptionViewItem qsovi;
QRect rect = style->subElementRect(QStyle::SE_ItemViewItemText, &qsovi);
Q_ASSERT(rect.height() > 0); // <- triggered!

Obviously, I'm missing some initialization here. The only examples I could find copy the options data from some preexistent object, but I have nothing to copy them from - I need the default for the current style. Suggestions, anyone?

sigil
  • 815
  • 8
  • 16
  • To set the default row height of a table you can use: `myTable->verticalHeader()->setDefaultSectionSize(size);` So I think you can get it with `myTable->verticalHeader()->defaultSectionSize();` Maybe the problem is that you have to create a table. – Fabio Jan 27 '17 at 13:18
  • Just checked it: `verticalHeader()->defaultSectionSize()` returns 37 in my case. No kidding. 37 for a simple text table row. It's way too much. However, I do not want to set it to some arbitrary value - it has to be consistent with other item views. – sigil Jan 27 '17 at 13:35

0 Answers0