I have a PySide6 Qt screen that looks like this:
The problem is that I want the buttons "0 test1.rtf," "1 test2.rtf," "2 test3.rtf," etc... to populate at the top left of the scroll area without dynamic spacing in between them which incorrectly makes the buttons fill up the entire area.
See how the spacing between the buttons dynamically changes when I add buttons:
I have the following code for my PySide6 Qt screen:
wid = QtWidgets.QWidget()
grid = QtWidgets.QVBoxLayout(wid)
# setting the inner widget and layout
grid_inner = QtWidgets.QVBoxLayout(wid)
wid_inner = QtWidgets.QWidget(wid)
wid_inner.setLayout(grid_inner)
# add the inner widget to the outer layout
grid.addWidget(wid_inner)
# add tab frame to widget
wid_inner.tab = QtWidgets.QTabWidget(wid_inner)
grid_inner.addWidget(wid_inner.tab)
# create tab
new_tab = QtWidgets.QScrollArea(wid_inner.tab)
grid_tab_1 = QtWidgets.QVBoxLayout(new_tab)
new_tab.tab_name_private = "test1"
wid_inner.tab.addTab(new_tab, "test1")
for idx, tx in enumerate(self.log):
fname_array = (tx.file_name).split('/')
btn = QtWidgets.QPushButton(str(idx) + ' ' + fname_array[(len(fname_array)) - 1])
btn.clicked.connect(lambda checked=False, x=idx: self.display_transaction(x))
grid_tab_1.addWidget(btn)
# create tab 2
new_tab2 = QtWidgets.QScrollArea(wid_inner.tab)
grid_tab_2 = QtWidgets.QVBoxLayout(new_tab2)
wid_inner.tab.addTab(new_tab2, "test2")
for idx, tx in enumerate(self.log):
fname_array = (tx.file_name).split('/')
btn = QtWidgets.QPushButton(str(idx) + ' ' + fname_array[(len(fname_array)) - 1])
btn.clicked.connect(lambda checked=False, x=idx: self.display_transaction(x))
grid_tab_2.addWidget(btn)
continue_btn = QtWidgets.QPushButton("Ok")
self.layout = QtWidgets.QVBoxLayout()
self.layout.addWidget(wid)
self.layout.addWidget(continue_btn)
self.setLayout(self.layout)
continue_btn.clicked.connect(self.continue_to_main)
How do I alter my code to get the screen to look the way I want?