How to remove the distance between PyQt5 containers
-
There's a white strip between the two containers.
How do you put it away?
from PyQt5.Qt import * import sys
class Window(QWidget):
def init(self, parent = None):
QWidget.init(self, parent)self.setMinimumSize(1000,500) self.top_bar = QFrame() self.content = QFrame() self.left_bar = QFrame() self.vbox = QVBoxLayout() self.hbox = QHBoxLayout() self.hbox.setContentsMargins(0, 0, 0, 0) self.top_bar.setStyleSheet("background-color: rgb(45,45,45);") self.left_bar.setStyleSheet("background-color: rgb(45,45,45);") self.content.setStyleSheet("background-color: rgb(35,35,35);") self.hbox.addWidget(self.left_bar) self.top_bar.setMaximumHeight(40) self.left_bar.setMaximumWidth(80) self.hbox.setSpacing(0) self.hbox.addWidget(self.left_bar) self.vbox.addWidget(self.top_bar) self.vbox.addWidget(self.content) self.hbox.addLayout(self.vbox) self.setLayout(self.hbox)
if name == "main":
app = QApplication(sys.argv)
window = Window()
window.show()
sys.exit(app.exec_())
-
I didn't change the lines, I just fixed them to figure out what's going on, and everything just got back on.
import sys from PyQt5.Qt import *
class Window(QWidget):
def init(self, parent = None):
super().init(parent)self.setMinimumSize(1000,500)
self.resize(1000,500) self.top_bar = QFrame() self.top_bar.setStyleSheet("background-color: rgb(45,45,145);") self.top_bar.setMaximumHeight(40) self.content = QFrame() self.content.setStyleSheet("background-color: rgb(35,135,35);") self.vbox = QVBoxLayout() self.vbox.addWidget(self.top_bar) self.vbox.addWidget(self.content) self.left_bar = QFrame() self.left_bar.setStyleSheet("background-color: rgb(145,45,45);") self.left_bar.setMaximumWidth(80) self.hbox = QHBoxLayout(self) self.hbox.setContentsMargins(0, 0, 0, 0) self.hbox.setSpacing(0) self.hbox.addWidget(self.left_bar) self.hbox.addLayout(self.vbox)
if name == "main":
app = QApplication(sys.argv)
window = Window()
window.show()
sys.exit(app.exec_())