zhiyiYo / PyQt-Fluent-Widgets

A fluent design widgets library based on C++ Qt/PyQt/PySide. Make Qt Great Again.
https://qfluentwidgets.com
GNU General Public License v3.0
5.61k stars 541 forks source link

[Bug]: ExpandLayout在控件不显示的情况下仍然计算位置 #597

Closed wsyong111 closed 11 months ago

wsyong111 commented 12 months ago

What happened?

当控件被使用addWidget添加到ExpandLayout中时对控件使用hide函数,控件依然会占用空间

如果这是预计行为请告诉我,并删除这个Issue

Operation System

Windows10 22H2

Python Version

Python 3.9.5 64Bit

PyQt/PySide Version

PyQt6

PyQt/PySide-Fluent-Widgets Version

1.3.4

How to Reproduce?

将部件添加到ExpandLayout中,调用控件的hide函数 结果:控件即使被隐藏了依然会占位

Minimum code

from PyQt6.QtWidgets import QApplication, QMainWindow, QPushButton, QWidget
from qfluentwidgets import ExpandLayout

class Gui(QMainWindow):
    def __init__(self):
        super().__init__()

        self.resize(400, 400)

        self.content = QWidget(self)
        self.layout = ExpandLayout(self.content)

        self.btn1 = QPushButton("Button1", self.content)
        self.btn1.hide()

        self.btn2 = QPushButton("Button2", self.content)

        self.layout.addWidget(self.btn1)
        self.layout.addWidget(self.btn2)

        self.setCentralWidget(self.content)

app = QApplication([])

win = Gui()
win.show()

app.exec()
rainzee commented 12 months ago

这是由于未考虑控件可见性导致的,我已经修复。现在当控件不可见时,将直接跳该控件不进行布局,进而处理下一个控件。详情见 #599