Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[问题]请教 动态设置流布局 Qwidget单元宽高,不管用resize还是setMaximumSize,setMinimumSize等都有问题。谢谢 #87

Closed
chybcool opened this issue Aug 23, 2019 · 0 comments

Comments

@chybcool
Copy link

Environment : / 环境

  • OS: [e.g. Win 7]
  • Python [e.g. 2.7.15]
  • PyQt5 [e.g. 4]

1.流布局里动态设置单元Qwidget宽高,使用setMaximumSize,resize,setMiniMumSize时,单元宽高不是设定值(如设定宽300 高100),而是80*77的宽高,并报有错:
QWidget::setLayout: Attempting to set QLayout "" on ShowScreen "", which already has a layout
2.如果用setFixedSize是可以得到设定值,但只是初始化的值,无法动态再修改。

代码 :

flowlayout = FlowLayout()
flowlayout.setSpacing(1)
flowlayout.setContentsMargins(0,0,0,0)
flowlayout.setAlignment(QtCore.Qt.AlignCenter)
QButtonGroup = QtGui.QButtonGroup(self)
QButtonGroup.setExclusive(True)
for i in range(self.rowslist):
      grid_widget = QtGui.QWidget(self)
      grid_widget.setMaxiMumSize(self.cabinetw,self.cabineth)  
      grid_widget.setContentsMargins(0, 0, 0, 0)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants