1

我的 QT 代码中的小部件之间存在空白空间问题。我尝试了填充,边距,但没有...

尝试在 QWidget、QVBoxLayout 上设置样式和 setMargin 但没有任何结果。

截图:http: //imageshack.us/a/img515/4796/gami.png

def __init__(self, GamiObject):
    """ Create initial window to put contents of installer to (layout) """

    self.Gami = GamiObject
    self.app = QApplication(sys.argv)
    self.window = QWidget()
    self.window.setWindowTitle("Instalator systemu Gentoo Linux")

    self.window.setMinimumSize(600, 350)
    self.layout = QVBoxLayout()
    self.layout.setMargin(0)

    # Title layout {
    TLay = QWidget()
    TLay.setAttribute(Qt.WA_TranslucentBackground, True)
    TLay.setStyleSheet("margin: 0; padding: 0; background-color: rgb(20,20,20, 50%);")
    TLay.setMaximumHeight(80)  
    TLay.setMinimumHeight(80)


    TLayStyle = QHBoxLayout()
    #TLayStyle.setAttribute(Qt.WA_TranslucentBackground, True)
    TLayStyle.addWidget(QLabel("Etap 1/4 - wybor lokalizacji"))

    TLay.setLayout(TLayStyle)
    # Title layout }

    # Empty space {

    self.Content = QFrame()

    # Empty Space }

    # Down layout {
    HBox = QWidget()
    HBoxLayout = QHBoxLayout()
    HBoxLayout.setSpacing(10)
    HBoxLayout.setMargin(0)

    buttonBack = QPushButton("Wstecz")
    buttonNext = QPushButton("Dalej")

    # Signals
    self.window.connect(buttonBack, SIGNAL("clicked()"), self.Gami.previousStep)
    self.window.connect(buttonNext, SIGNAL("clicked()"), self.Gami.nextStep)

    self.Gami.Hooking.connectHook("Gami.previousStep", self.buttonPrevious)
    self.Gami.Hooking.connectHook("Gami.nextStep", self.buttonNext)

    #buttonBack.setMinimumWidth(50)
    buttonBack.setMaximumWidth(100)
    buttonBack.setMinimumWidth(90)
    buttonBack.setMinimumHeight(45)
    buttonBack.setDisabled(True)

    #buttonNext.setMinimumWidth(50)
    buttonNext.setMaximumWidth(100)
    buttonNext.setMinimumWidth(90)
    buttonNext.setMinimumHeight(45)


    HBoxLayout.addWidget(buttonBack, 1, alignment=Qt.Alignment(2))
    HBoxLayout.addWidget(buttonNext, 0, alignment=Qt.Alignment(2))
    HBox.setLayout(HBoxLayout)
    HBox.setStyleSheet("margin: 4px;")

    # Down layout }

    self.layout.addWidget(TLay)
    self.layout.addWidget(self.Content, 1)
    self.layout.addWidget(HBox)

    self.window.setLayout(self.layout)
    self.window.show()

    self.app.exec_()
4

0 回答 0