Comments (5)
无法复现,我的代码
import random
import sys
from PyQt5.QtCore import QEasingCurve, QTimer
from PyQt5.QtWidgets import QApplication, QPushButton, QWidget
from qfluentwidgets import FlowLayout
class Demo(QWidget):
def __init__(self):
super().__init__()
self.refreshTimer = QTimer(self)
self.refreshTimer.timeout.connect(self.refresh)
self.refreshTimer.start(1000)
self.mainLyoaut = FlowLayout(self, needAni=True)
# customize animation
self.mainLyoaut.setAnimation(250, QEasingCurve.OutQuad)
self.mainLyoaut.setContentsMargins(30, 30, 30, 30)
self.mainLyoaut.setVerticalSpacing(20)
self.mainLyoaut.setHorizontalSpacing(10)
self.mainLyoaut.addWidget(QPushButton("aiko"))
self.mainLyoaut.addWidget(QPushButton("刘静爱"))
self.mainLyoaut.addWidget(QPushButton("柳井爱子"))
self.mainLyoaut.addWidget(QPushButton("aiko 赛高"))
self.mainLyoaut.addWidget(QPushButton("aiko 太爱啦😘"))
self.mainLyoaut.addWidget(QPushButton("aiko"))
self.mainLyoaut.addWidget(QPushButton("刘静爱"))
self.mainLyoaut.addWidget(QPushButton("柳井爱子"))
self.mainLyoaut.addWidget(QPushButton("aiko 赛高"))
self.mainLyoaut.addWidget(QPushButton("aiko 太爱啦😘"))
self.mainLyoaut.addWidget(QPushButton("aiko"))
self.mainLyoaut.addWidget(QPushButton("刘静爱"))
self.mainLyoaut.addWidget(QPushButton("柳井爱子"))
self.mainLyoaut.addWidget(QPushButton("aiko 赛高"))
self.mainLyoaut.addWidget(QPushButton("aiko 太爱啦😘"))
self.mainLyoaut.addWidget(QPushButton("aiko"))
self.mainLyoaut.addWidget(QPushButton("刘静爱"))
self.mainLyoaut.addWidget(QPushButton("柳井爱子"))
self.mainLyoaut.addWidget(QPushButton("aiko 赛高"))
self.mainLyoaut.addWidget(QPushButton("aiko 太爱啦😘"))
self.resize(250, 300)
self.setStyleSheet('Demo{background: white} QPushButton{padding: 5px 10px; font:15px "Microsoft YaHei"}')
def refresh(self):
self.mainLyoaut.takeAllWidgets()
for i in range(10):
self.mainLyoaut.addWidget(QPushButton(str(random.randint(0, 100))))
if __name__ == "__main__":
app = QApplication(sys.argv)
w = Demo()
w.show()
app.exec()
from pyqt-fluent-widgets.
您的代码,我也运行了,确实没有异常问题,但加上滚动区域:
self.scrollArea = SmoothScrollArea(self)
self.scrollWidget = QWidget(self.scrollArea)
即可复现出现问题
from pyqt-fluent-widgets.
你的写法是错误的,按照我这个写,这里没问题,issue可以关了
import random
from typing import Optional
from PyQt5.QtCore import Qt, QTimer
from PyQt5.QtWidgets import QApplication, QWidget
from qfluentwidgets import FlowLayout, PushButton, SmoothScrollArea
class SegmentedView(SmoothScrollArea):
def __init__(self, parent: Optional[QWidget] = None) -> None:
super().__init__(parent=parent)
self.refreshTimer = QTimer(self)
self.refreshTimer.timeout.connect(self.refresh)
self.refreshTimer.start(1000)
# instant widget
self.viewContainer = QWidget()
# instant layout
self.viewContainerLayout = FlowLayout(self.viewContainer, needAni=True)
# init
self._initWidget()
self._initLayout()
def _initWidget(self) -> None:
self.setWidget(self.viewContainer)
self.setWidgetResizable(True)
self.setHorizontalScrollBarPolicy(Qt.ScrollBarPolicy.ScrollBarAlwaysOff)
self.setViewportMargins(0, 5, 0, 5)
self.setStyleSheet("border: none;")
self.resize(400, 300)
def _initLayout(self) -> None:
for _ in range(100):
self.viewContainerLayout.addWidget(PushButton(str(random.randint(0, 100))))
def refresh(self):
self.viewContainerLayout.takeAllWidgets()
self._initLayout()
if __name__ == "__main__":
app = QApplication([])
w = SegmentedView()
w.show()
app.exec()
from pyqt-fluent-widgets.
厉害,👍👍👍。问题解决了,但是不知道为什么,可以点播一下吗😀
from pyqt-fluent-widgets.
关键在于实例化FlowLayout(self.viewContainer, needAni=True, isTight=True)
的时候,去掉isTight=True
from pyqt-fluent-widgets.
Related Issues (20)
- [Bug]: SearchLineEdit 设置QCompleter 后,Completer 的 void activated(const QModelIndex &index); 没触发
- Windows系统的主题色发生改变时,整个界面会自动变白[Bug]: HOT 6
- 希望作者大佬在QConfig中支持普通字符串
- 新组件提议:InputDialog(已实现完整功能) HOT 1
- [Bug]: 使用pyqtgraph绘制动态曲线后切换interface报错 HOT 1
- 多屏下启用亚克力效果的导航菜单背景异常
- 对话框偶尔报错 QPainter::begin HOT 3
- [Bug]: Change background of ListWidget item HOT 2
- [Bug]: InfoBadge covers navigation menu, but it can't be clicked.
- [Bug]: FramelessWebEngineView加载url很慢 HOT 2
- [Bug]: TableWidget掉帧问题
- FlowLayout中的控件在ExpandSettingCard中无法全部显示问题
- [Bug]: Pro组件中的GuideWindow在Mac下显示了Mac自带的最小化最大化和关闭按钮,且下一步和启动按钮的文案未翻译
- table显示较长文本时,希望能偶有方法看清完整文本。 HOT 1
- [Bug]: 继承'SplitFluentWindow'加载html会导致侧边栏显示异常,图标消失
- [Bug]: TableWidget安装了事件过滤器后无法监听鼠标按下的事件 HOT 3
- 流式布局添加 insertWidget 接口
- `Pivot` 组件 `setCurrentItem` 方法在初始化阶段无效
- `Pivot` 组件在设置图标后,点击偏移
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pyqt-fluent-widgets.