<p>下面是另一个使用PySide的解决方案:</p>
<pre><code>from PySide.QtGui import QFrame
class QHLine(QFrame):
def __init__(self):
super(QHLine, self).__init__()
self.setFrameShape(QFrame.HLine)
self.setFrameShadow(QFrame.Sunken)
class QVLine(QFrame):
def __init__(self):
super(QVLine, self).__init__()
self.setFrameShape(QFrame.VLine)
self.setFrameShadow(QFrame.Sunken)
</code></pre>
<p>然后可用作(例如):</p>
<pre><code>from PySide.QtGui import QApplication, QWidget, QGridLayout, QLabel, QComboBox
if __name__ == "__main__":
app = QApplication([])
widget = QWidget()
layout = QGridLayout()
layout.addWidget(QLabel("Test 1"), 0, 0, 1, 1)
layout.addWidget(QComboBox(), 0, 1, 1, 1)
layout.addWidget(QHLine(), 1, 0, 1, 2)
layout.addWidget(QLabel("Test 2"), 2, 0, 1, 1)
layout.addWidget(QComboBox(), 2, 1, 1, 1)
widget.setLayout(layout)
widget.show()
app.exec_()
</code></pre>
<p>结果如下:</p>
<p><a href="https://i.stack.imgur.com/gsH9M.png" rel="noreferrer"><img src="https://i.stack.imgur.com/gsH9M.png" alt="Example of QHLine on Windows 10"/></a></p>