summaryrefslogtreecommitdiffstats
path: root/src/widgets
diff options
context:
space:
mode:
Diffstat (limited to 'src/widgets')
-rw-r--r--src/widgets/itemviews/qtableview.cpp22
-rw-r--r--src/widgets/styles/qstyle.cpp5
-rw-r--r--src/widgets/styles/qstyle.h1
3 files changed, 28 insertions, 0 deletions
diff --git a/src/widgets/itemviews/qtableview.cpp b/src/widgets/itemviews/qtableview.cpp
index b261ee837d..384a34d5a1 100644
--- a/src/widgets/itemviews/qtableview.cpp
+++ b/src/widgets/itemviews/qtableview.cpp
@@ -1644,6 +1644,28 @@ void QTableView::paintEvent(QPaintEvent *event)
colp += columnWidth(col) - gridSize;
painter.drawLine(colp, dirtyArea.top(), colp, dirtyArea.bottom());
}
+ const bool drawWhenHidden = style()->styleHint(QStyle::SH_Table_AlwaysDrawLeftTopGridLines,
+ &option, this);
+ if (drawWhenHidden && horizontalHeader->isHidden()) {
+ const int row = verticalHeader->logicalIndex(top);
+ if (!verticalHeader->isSectionHidden(row)) {
+ const int rowY = rowViewportPosition(row) + offset.y();
+ if (rowY == dirtyArea.top())
+ painter.drawLine(dirtyArea.left(), rowY, dirtyArea.right(), rowY);
+ }
+ }
+ if (drawWhenHidden && verticalHeader->isHidden()) {
+ const int col = horizontalHeader->logicalIndex(left);
+ if (!horizontalHeader->isSectionHidden(col)) {
+ int colX = columnViewportPosition(col) + offset.x();
+ if (!isLeftToRight())
+ colX += columnWidth(left) - 1;
+ if (isLeftToRight() && colX == dirtyArea.left())
+ painter.drawLine(colX, dirtyArea.top(), colX, dirtyArea.bottom());
+ if (!isLeftToRight() && colX == dirtyArea.right())
+ painter.drawLine(colX, dirtyArea.top(), colX, dirtyArea.bottom());
+ }
+ }
painter.setPen(old);
}
}
diff --git a/src/widgets/styles/qstyle.cpp b/src/widgets/styles/qstyle.cpp
index 857c894c00..5e760b4531 100644
--- a/src/widgets/styles/qstyle.cpp
+++ b/src/widgets/styles/qstyle.cpp
@@ -2013,6 +2013,11 @@ void QStyle::drawItemPixmap(QPainter *painter, const QRect &rect, int alignment,
of a QTabBar.
This enum value has been introduced in Qt 6.1.
+ \value SH_Table_AlwaysDrawLeftTopGridLines
+ Determines if the far left and top grid lines are drawn in a table or
+ not when the header is hidden. Defaults to false.
+ This enum value has been introduced in Qt 6.2.
+
\sa styleHint()
*/
diff --git a/src/widgets/styles/qstyle.h b/src/widgets/styles/qstyle.h
index c3c99d9974..66768be671 100644
--- a/src/widgets/styles/qstyle.h
+++ b/src/widgets/styles/qstyle.h
@@ -736,6 +736,7 @@ public:
SH_SpinBox_ButtonsInsideFrame,
SH_SpinBox_StepModifier,
SH_TabBar_AllowWheelScrolling,
+ SH_Table_AlwaysDrawLeftTopGridLines,
// Add new style hint values here
SH_CustomBase = 0xf0000000