This is my current window layout, I want to have it split up into 1/4, and not 1/2 so to speak.
This is how I want my window to look, but I can't seem to find a good way to resize the QGridLayout
to the way I want, and the way setColumnStretch
works still confuses me and I don't fully understand how it works.
This is my code for this windows layout:
self.pathRoot = QDir.rootPath()
self.labelFileName = QLabel(self)
self.labelFileName.setText("Search:")
self.labelFileName.resize(100, 30)
self.txtSearch = QLineEdit(self)
self.txtSearch.textChanged.connect(self.on_textChanged)
self.btnBack = QPushButton('Back', self)
self.btnBack.clicked.connect(self.back)
self.model = QFileSystemModel()
self.model.setRootPath(QDir.rootPath())
self.model.setFilter(QDir.NoDotAndDotDot | QDir.AllEntries | QDir.Dirs | QDir.Files)
self.proxy_model = QSortFilterProxyModel(recursiveFilteringEnabled = True, filterRole = QFileSystemModel.FileNameRole)
self.proxy_model.setSourceModel(self.model)
self.model.setReadOnly(False)
self.model.setNameFilterDisables(False)
self.indexRoot = self.model.index(self.model.rootPath())
self.treeView = QTreeView(self)
self.treeView.setModel(self.proxy_model)
self.adjust_root_index()
self.treeView.setRootIndex(self.indexRoot)
self.treeView.clicked.connect(self.on_treeView_clicked)
self.treeView.doubleClicked.connect(self.treeMedia_doubleClicked)
self.treeView.setAnimated(True)
self.treeView.setIndentation(20)
self.treeView.setSortingEnabled(True)
self.treeView.setDragEnabled(False)
self.treeView.setAcceptDrops(False)
self.treeView.setDropIndicatorShown(True)
self.treeView.setEditTriggers(QTreeView.NoEditTriggers)
self.treeView.setContextMenuPolicy(Qt.CustomContextMenu)
self.treeView.customContextMenuRequested.connect(self.showContextMenu)
for i in range(1, self.treeView.model().columnCount()):
self.treeView.header().hideSection(i)
self.gridLayout = QGridLayout()
self.gridLayout.addWidget(self.labelFileName, 0, 0)
self.gridLayout.addWidget(self.btnBack, 2, 0)
self.gridLayout.addWidget(self.txtSearch, 1, 0)
self.gridLayout.addWidget(self.treeView, 3, 0)
self.gridLayout1 = QGridLayout()
self.progressbar = QProgressBar(self)
self.lblProgress = QLabel('0/0', self)
self.btnClearBatches = QPushButton('Clear Batches', self)
self.btnClearBatches.clicked.connect(self.clear_batches)
self.layout = QHBoxLayout(self)
self.layout.addLayout(self.gridLayout)
self.layout.addLayout(self.gridLayout1)
self.scroll = QScrollArea(self)
self.gridLayout1.addWidget(self.scroll, 0, 0)
self.gridLayout1.addWidget(self.lblProgress, 1, 0)
self.gridLayout1.addWidget(self.progressbar, 2, 0)
self.gridLayout1.addWidget(self.btnClearBatches, 3, 0)
self.scroll.move(7, 80)
self.scroll.setWidgetResizable(True)
self.content = QWidget()
self.scroll.setWidget(self.content)
self.lay = QGridLayout(self.content)