Skip to content

Commit 1c90b3b

Browse files
authored
为可用选项添加滚动区域并设置样式 (#60)
1 parent fc0f413 commit 1c90b3b

1 file changed

Lines changed: 11 additions & 3 deletions

File tree

ok/gui/tasks/ModifyListDialog.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
from PySide6.QtCore import Signal
2-
from PySide6.QtWidgets import QHBoxLayout, QVBoxLayout, QWidget
1+
from PySide6.QtCore import Signal, Qt
2+
from PySide6.QtWidgets import QHBoxLayout, QScrollArea, QVBoxLayout, QWidget
33
from qfluentwidgets import (
44
BodyLabel, FlowLayout, MessageBoxBase, SubtitleLabel, ListWidget, PushButton, FluentIcon,
55
LineEdit
@@ -58,7 +58,14 @@ def __init__(self, items, parent, options_available=None, allow_duplication=Fals
5858
available_layout = QVBoxLayout()
5959
available_layout.addWidget(SubtitleLabel(self.tr("Available Options"), self))
6060
available_layout.addWidget(BodyLabel(self.tr("Click an option to add it."), self))
61-
available_layout.addWidget(self._create_available_options_widget(), stretch=1)
61+
available_scroll_area = QScrollArea(self)
62+
available_scroll_area.setWidgetResizable(True)
63+
available_scroll_area.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
64+
available_scroll_area.setFrameShape(QScrollArea.NoFrame)
65+
available_scroll_area.setStyleSheet("QScrollArea { background-color: transparent; border: none; }")
66+
available_scroll_area.viewport().setStyleSheet("background-color: transparent;")
67+
available_scroll_area.setWidget(self._create_available_options_widget())
68+
available_layout.addWidget(available_scroll_area, stretch=1)
6269

6370
selected_layout = QVBoxLayout()
6471
selected_layout.addWidget(SubtitleLabel(self.tr("Selected Options"), self))
@@ -95,6 +102,7 @@ def _create_selected_list_layout(self):
95102

96103
def _create_available_options_widget(self):
97104
widget = QWidget()
105+
widget.setStyleSheet("background-color: transparent;")
98106
layout = FlowLayout(widget, False)
99107
layout.setContentsMargins(0, 0, 0, 0)
100108
layout.setHorizontalSpacing(10)

0 commit comments

Comments
 (0)