Python:如何使QGroupBox无边框

时间:2014-03-27 20:17:32

标签: python pyqt

需要设置什么QGroupBox属性来隐藏其轮廓边框?

enter image description here

from PyQt4 import QtGui, QtCore
import sys, os


class Dialog_01(QtGui.QMainWindow):
    def __init__(self):
        super(QtGui.QMainWindow,self).__init__()

        mainWidget=QtGui.QWidget()
        self.setCentralWidget(mainWidget)
        mainLayout = QtGui.QVBoxLayout()
        mainWidget.setLayout(mainLayout)

        tabWidget = QtGui.QTabWidget()
        mainLayout.addWidget(tabWidget)

        WidgetA = QtGui.QWidget()
        LayoutA = QtGui.QVBoxLayout()
        WidgetA.setLayout(LayoutA)

        GroupBox1 = QtGui.QGroupBox('Goupbox 1') 
        Layout1 = QtGui.QHBoxLayout()
        GroupBox1.setLayout(Layout1)
        LayoutA.addWidget(GroupBox1)

        GroupBox2 = QtGui.QGroupBox('Goupbox 2') 
        Layout2 = QtGui.QHBoxLayout()
        GroupBox2.setLayout(Layout2)
        Layout1.addWidget(GroupBox2)

        GroupBox3 = QtGui.QGroupBox('Goupbox 3') 
        Layout3 = QtGui.QHBoxLayout()
        GroupBox3.setLayout(Layout3)
        Layout2.addWidget(GroupBox3)

        tabWidget.addTab(WidgetA,'A')     

        tabWidget.addTab(QtGui.QWidget(),'B')
        tabWidget.addTab(QtGui.QWidget(),'C')



if __name__ == '__main__':
    app = QtGui.QApplication(sys.argv)
    dialog_1 = Dialog_01()
    dialog_1.show()
    dialog_1.resize(480,320)
    sys.exit(app.exec_())

1 个答案:

答案 0 :(得分:1)

您可以尝试QGroupBox.setFlat,但具体结果将取决于当前使用的小部件样式。