I have a QListWidget inside a layout, and I have that ListWidget/Layout inside my main layout, and whenever i do ListWidget.Show the entire main layout get's messed up. It looks like it get's a bigger spacing or something, however I can't find out why it would do that. Anyone seen anything like it before?
Before ListWidget added:
3bf1d57ba270350613cb6e4bb17d6f61.png
After ListWidget added:
e4778e9d56601fb2dad3af044015953f.png
Code example if how listwidget is added (This is PyQt 5.8.2 in python 3.6)
First it's added thru the UI-Designer
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(self.playlist_List.sizePolicy().hasHeightForWidth())
self.playlist_List.setSizePolicy(sizePolicy)
self.playlist_List.setFocusPolicy(QtCore.Qt.ClickFocus)
self.playlist_List.setObjectName("playlist_List")
self.playlist_Layout.addWidget(self.playlist_List, 0, 0, 1, 1)
self.playlist_List = QtWidgets.QListWidget(Form)
sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(self.playlist_List.sizePolicy().hasHeightForWidth())
self.playlist_List.setSizePolicy(sizePolicy)
self.playlist_List.setFocusPolicy(QtCore.Qt.ClickFocus)
self.playlist_List.setEditTriggers(QtWidgets.QAbstractItemView.NoEditTriggers)
self.playlist_List.setObjectName("playlist_List")
self.playlist_Layout.addWidget(self.playlist_List, 0, 0, 1, 1)
To copy to clipboard, switch view to plain text mode
Then I create a new Layout, name it bottomLayout and adds that widget to it.
self.bottomLayout.setContentsMargins(0, 0, 0, 0)
self.bottomLayout.setSpacing(6)
self.bottomLayout.addLayout(self.playlist_Layout)
self.bottomLayout = QVBoxLayout()
self.bottomLayout.setContentsMargins(0, 0, 0, 0)
self.bottomLayout.setSpacing(6)
self.bottomLayout.addLayout(self.playlist_Layout)
To copy to clipboard, switch view to plain text mode
Note: This is the layout that gets added to bottomLayout
self.
playlist_Layout.
setSizeConstraint(QtWidgets.
QLayout.
SetDefaultConstraint) self.playlist_Layout.setContentsMargins(6, -1, 6, -1)
self.playlist_Layout.setSpacing(0)
self.playlist_Layout = QtWidgets.QGridLayout()
self.playlist_Layout.setSizeConstraint(QtWidgets.QLayout.SetDefaultConstraint)
self.playlist_Layout.setContentsMargins(6, -1, 6, -1)
self.playlist_Layout.setSpacing(0)
To copy to clipboard, switch view to plain text mode
Bookmarks