I am trying to centre a line of widgets in a QGridLayout using pyqt6. I have the widgets in the line and the first few are not made any bigger than the default, but the last one I would like to have made bigger as it's the most important box that is there. My code looks like below (I have tried to add only the important bits as the full code is quite long)
class runTest(QWidget):
def __init__(self, mylogs, data):
super().__init__()
self.data = data
self.mylogs = mylogs
self.mylogs.info("Starting run test window")
self.setWindowTitle("Running Test")
layout = QGridLayout()
self.progEnocean = QLabel("Enocean Program Results")
layout.addWidget(self.progEnocean, 0, 0)
self.progEnocean.setStyleSheet("border: 1px solid black;")
self.enoceanProgFile = QLabel("EnOcean Program File")
layout.addWidget(self.enoceanProgFile, 0, 1)
self.enoceanProgFile.setStyleSheet(
"border: 1px solid black;" "background-color: Red;"
)
self.enoceanProgFile.setAlignment(
Qt.AlignmentFlag.AlignHCenter | Qt.AlignmentFlag.AlignVCenter
)
self.seccfgFile = QLabel("Secure Config File")
layout.addWidget(self.seccfgFile, 0, 2)
self.seccfgFile.setStyleSheet(
"border: 1px solid black;" "background-color: Red;"
)
self.seccfgFile.setAlignment(
Qt.AlignmentFlag.AlignHCenter | Qt.AlignmentFlag.AlignVCenter
)
self.cpbBit = QLabel("Config File")
layout.addWidget(self.cpbBit, 0, 3)
self.cpbBit.setStyleSheet("border: 1px solid black;" "background-color: Red;")
self.cpbBit.setAlignment(
Qt.AlignmentFlag.AlignHCenter | Qt.AlignmentFlag.AlignVCenter
)
self.enoceanOverallResult = QLabel("EnOcean Overall Results")
layout.addWidget(self.enoceanOverallResult, 0, 4, 2, 2)
self.enoceanOverallResult.setStyleSheet(
"border: 1px solid black;" "background-color: Red;"
)
self.enoceanOverallResult.setAlignment(
Qt.AlignmentFlag.AlignHCenter | Qt.AlignmentFlag.AlignVCenter
)
self.setLayout(layout)
Currently, the widgets look like this,
I would like the first four to be in the centre of the line, not justified with the top or bottom of the final box, is there a way to do this?