Skip to content

Commit

Permalink
fix: DTitleBar动态设置Icon时间距异常
Browse files Browse the repository at this point in the history
spacerItem多次设置,改为设置前先移除之前的

Log:
  • Loading branch information
Whale107 committed Jul 5, 2024
1 parent 8df23f4 commit e8f6dc8
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/widgets/dtitlebar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -775,6 +775,9 @@ void DTitlebarPrivate::setIconVisible(bool visible)
return;

if (visible) {
if (auto spacerItem = dynamic_cast<QSpacerItem *>(leftLayout.takeAt(0)))
delete leftLayout->takeAt(0);

leftLayout->insertSpacing(0, 10);
leftLayout->insertWidget(1, iconLabel, 0, Qt::AlignLeading | Qt::AlignVCenter);
iconLabel->show();
Expand Down

0 comments on commit e8f6dc8

Please sign in to comment.