How to get rid of the white strip between the sights of QVBoxLayout
-
I'm trying to figure out the containers. I understand that the containers create a frame between the sights added.
How do you get rid of her?
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.vbox = QVBoxLayout() self.vbox.setContentsMargins(0,0,0,0) self.top_bar.setStyleSheet("background-color: rgb(45,45,45);") self.content.setStyleSheet("background-color: rgb(35,35,35);") self.top_bar.setMaximumHeight(40) self.vbox.addWidget(self.top_bar) self.vbox.addWidget(self.content) self.setLayout(self.vbox)
if name == "main":
app = QApplication(sys.argv)
window = Window()
window.show()
sys.exit(app.exec_())
-
void QBoxLayout::setSpacing(int spacing)
Sets a spacing point.
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.vbox = QVBoxLayout() self.vbox.setContentsMargins(0,0,0,0) self.vbox.setSpacing(0) # +++ self.top_bar.setStyleSheet("background-color: rgb(45,45,45);") self.content.setStyleSheet("background-color: rgb(35,35,135);") self.top_bar.setMaximumHeight(40) self.vbox.addWidget(self.top_bar) self.vbox.addWidget(self.content) self.setLayout(self.vbox)
if name == "main":
app = QApplication(sys.argv)
window = Window()
window.show()
sys.exit(app.exec_())