Skip to content

Commit

Permalink
fix: fix the problem of text position in dstyleditemdelegate
Browse files Browse the repository at this point in the history
as title

log: as title
issue: linuxdeepin/developer-center#7673
  • Loading branch information
ssk-wh committed Apr 8, 2024
1 parent c1420ba commit 3b4fef5
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
2 changes: 2 additions & 0 deletions include/widgets/dlistview.h
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,8 @@ public Q_SLOTS:

#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
QStyleOptionViewItem viewOptions() const override;
#else
void initViewItemOption(QStyleOptionViewItem *option) const override;
#endif
virtual QModelIndex moveCursor(CursorAction cursorAction,
Qt::KeyboardModifiers modifiers) override;
Expand Down
14 changes: 14 additions & 0 deletions src/widgets/dlistview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -936,6 +936,20 @@ QStyleOptionViewItem DListView::viewOptions() const

return item;
}
#else
/*!
\reimp
*/
void DListView::initViewItemOption(QStyleOptionViewItem *option) const
{
QListView::initViewItemOption(option);
option->showDecorationSelected = true;
// 列表项不会变为Inactive状态
option->state |= QStyle::State_Active;
if (viewMode() == QListView::ListMode) {
option->decorationAlignment = Qt::AlignVCenter;
}
}
#endif

QModelIndex DListView::moveCursor(QAbstractItemView::CursorAction cursorAction, Qt::KeyboardModifiers modifiers)
Expand Down

0 comments on commit 3b4fef5

Please sign in to comment.