Skip to content

Commit 7fa8b02

Browse files
committed
Horizontal header of the table
1 parent 9800a43 commit 7fa8b02

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

sources/editor/widgets/tableheaderview.cpp

+3-5
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ TableHeaderView::TableHeaderView(QWidget *parent) : QHeaderView(Qt::Horizontal,
5454

5555
// Height of the header
5656
QFontMetrics fm(this->font());
57-
_height = (fm.height() + MARGIN) * 2;
57+
_height = fm.height() * 2;
5858
}
5959

6060
TableHeaderView::~TableHeaderView()
@@ -203,7 +203,7 @@ void TableHeaderView::paintSection(QPainter *painter, const QRect &rect, int log
203203
textRect.setWidth(textRect.width() - 2 * MARGIN);
204204
if (iconRect.width() > 0)
205205
textRect.setWidth(textRect.width() - iconRect.width() - MARGIN);
206-
textRect.translate(MARGIN, MARGIN);
206+
textRect.translate(MARGIN, 0);
207207

208208
// Adapt the text
209209
QString adaptedText = text;
@@ -213,8 +213,6 @@ void TableHeaderView::paintSection(QPainter *painter, const QRect &rect, int log
213213
lengthLine1--;
214214
if (lengthLine1 < text.length())
215215
adaptedText = text.left(lengthLine1) + "\n" + fm.elidedText(text.mid(lengthLine1), Qt::ElideRight, textRect.width());
216-
else
217-
textRect.translate(0, fm.height() / 2);
218216

219217
// First draw the cell without text or icon for the background and border
220218
this->model()->setHeaderData(logicalIndex, this->orientation(), "", Qt::DisplayRole);
@@ -228,7 +226,7 @@ void TableHeaderView::paintSection(QPainter *painter, const QRect &rect, int log
228226
if (foregroundBrush.canConvert<QBrush>())
229227
painter->setPen(foregroundBrush.value<QBrush>().color());
230228
painter->setClipRect(rect);
231-
painter->drawText(textRect, Qt::AlignHCenter, adaptedText);
229+
painter->drawText(textRect, Qt::AlignCenter, adaptedText);
232230

233231
// Finally draw the icon on the right and vertically centered
234232
int iconHeight = iconRect.height();

0 commit comments

Comments
 (0)