擅长:python、mysql、java
<p>只是更新布伦登·阿贝尔的答案:</p>
<p>QWidget和QVBoxLayout(对于Python3,PyQt5)现在包含在PyQt5.qtwidts模块中,而不是PyQt5.QtGui模块中</p>
<p>因此,更新代码:</p>
<pre><code>wid = QtWidgets.QWidget(self)
self.setCentralWidget(wid)
layout = QtWidgets.QVBoxLayout()
wid.setLayout(layout)
</code></pre>