删除QLabel和QLineEdit之间的边距

问题描述 投票:0回答:1

我正在尝试创建登录窗口,该窗口在QLabel下具有QLineEdit,但是当前的QLabel在Window中占用了太多空间,我不知道为什么,这是图片:

QLabel { background-color: red; }

“红色”

我的代码:

self.text = QLabel("LOGIN")

# self.text.setStyleSheet("QLabel { background-color: red; color : white;margin-top: 50px;margin-bottom: 0px; }")
self.text.setAlignment(Qt.AlignCenter)
# self.text.setContentsMargins(0, 0, 0, 0)
# self.text.setGeometry(QRect(10,10,30,80))

font = QFont("Sans-Serif", 30)
self.text.setFont(font)

form = QLineEdit("Write my name here..")
form.setAlignment(Qt.AlignCenter)
# form.setAlignment(Qt.AlignHCenter)

self.layout = QVBoxLayout()
# self.layout.setContentsMargins(0, 0, 0, 0)
self.layout.setSpacing(0)
self.layout.addWidget(self.text)
self.layout.addWidget(form)
self.layout.addWidget(self.button)
self.setLayout(self.layout)

enter image description here

我正在尝试创建登录窗口,该窗口在QLabel下具有QLineEdit,但是当前的QLabel在Window中占用了太多空间,我不知道为什么,这是图片:QLabel {background-color:red; } ...

python pyside2
1个回答
0
投票

我看不到OP提供的代码与要从中复制结构的LOGIN窗口之间的关系,因此请从头开始创建以下代码。

© www.soinside.com 2019 - 2024. All rights reserved.