提交 ddc6c5c6 编写于 作者: 之一Yo's avatar 之一Yo

修复流式布局的问题

上级 92211e5f
...@@ -133,7 +133,7 @@ class IconCardView(QWidget): ...@@ -133,7 +133,7 @@ class IconCardView(QWidget):
self.vBoxLayout = QVBoxLayout(self) self.vBoxLayout = QVBoxLayout(self)
self.hBoxLayout = QHBoxLayout(self.view) self.hBoxLayout = QHBoxLayout(self.view)
self.flowLayout = FlowLayout(self.scrollWidget) self.flowLayout = FlowLayout(self.scrollWidget, isTight=True)
self.cards = [] # type:List[IconCard] self.cards = [] # type:List[IconCard]
self.icons = [] self.icons = []
......
...@@ -12,7 +12,7 @@ Examples are available at https://github.com/zhiyiYo/PyQt-Fluent-Widgets/tree/ma ...@@ -12,7 +12,7 @@ Examples are available at https://github.com/zhiyiYo/PyQt-Fluent-Widgets/tree/ma
:license: GPLv3, see LICENSE for more details. :license: GPLv3, see LICENSE for more details.
""" """
__version__ = "0.6.0" __version__ = "0.6.1"
from .components import * from .components import *
from .common import * from .common import *
......
...@@ -8,7 +8,7 @@ from PyQt5.QtWidgets import QLayout, QWidgetItem, QLayoutItem ...@@ -8,7 +8,7 @@ from PyQt5.QtWidgets import QLayout, QWidgetItem, QLayoutItem
class FlowLayout(QLayout): class FlowLayout(QLayout):
""" Flow layout """ """ Flow layout """
def __init__(self, parent=None, needAni=False): def __init__(self, parent=None, needAni=False, isTight=False):
""" """
Parameters Parameters
---------- ----------
...@@ -17,6 +17,9 @@ class FlowLayout(QLayout): ...@@ -17,6 +17,9 @@ class FlowLayout(QLayout):
needAni: bool needAni: bool
whether to add moving animation whether to add moving animation
isTight: bool
whether to use the tight layout when widgets are hidden
""" """
super().__init__(parent) super().__init__(parent)
self._items = [] # type: List[QLayoutItem] self._items = [] # type: List[QLayoutItem]
...@@ -25,6 +28,7 @@ class FlowLayout(QLayout): ...@@ -25,6 +28,7 @@ class FlowLayout(QLayout):
self._verticalSpacing = 10 self._verticalSpacing = 10
self._horizontalSpacing = 10 self._horizontalSpacing = 10
self.needAni = needAni self.needAni = needAni
self.isTight = isTight
def addItem(self, item): def addItem(self, item):
self._items.append(item) self._items.append(item)
...@@ -147,7 +151,7 @@ class FlowLayout(QLayout): ...@@ -147,7 +151,7 @@ class FlowLayout(QLayout):
spaceY = self.verticalSpacing() spaceY = self.verticalSpacing()
for i, item in enumerate(self._items): for i, item in enumerate(self._items):
if item.widget() and not item.widget().isVisible() and not self.needAni: if item.widget() and not item.widget().isVisible() and self.isTight:
continue continue
nextX = x + item.sizeHint().width() + spaceX nextX = x + item.sizeHint().width() + spaceX
......
...@@ -6,7 +6,7 @@ with open('README.md', encoding='utf-8') as f: ...@@ -6,7 +6,7 @@ with open('README.md', encoding='utf-8') as f:
setuptools.setup( setuptools.setup(
name="PyQt-Fluent-Widgets", name="PyQt-Fluent-Widgets",
version="0.6.0", version="0.6.1",
keywords="pyqt fluent widgets", keywords="pyqt fluent widgets",
author="zhiyiYo", author="zhiyiYo",
author_email="shokokawaii@outlook.com", author_email="shokokawaii@outlook.com",
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册