how can i add blank lines of space to the QGridLayout?

31 Views Asked by At

For example I created a layout getting empty lines with this workaround, i.e. using __layout.setRowStretch But it seems cumbersome and not beautiful

list_fw_supported = self.wizard().get_list_fw_supported()
        list_fw_supported.append(self.NOT_SELECTED)
        __label_cbb_target_fw_ver = QLabel("Choose the target firmware version")
        self.__cbb_target_fw_ver = QComboBox()
        self.__cbb_target_fw_ver.addItems(list_fw_supported[::-1])
        self.__cbb_target_fw_ver.setCurrentText(self.NOT_SELECTED)
        self.__cbb_target_fw_ver.currentIndexChanged.connect(self.__CurrentIndexChanged)
        
        list_comPort_available = self.wizard().get_list_comPort_available()
        list_comPort_available.append(self.NOT_SELECTED)
        __label_cbb_IUT_comport = QLabel("Choose the IUT comport")
        self.__cbb_IUT_comport = QComboBox()
        self.__cbb_IUT_comport.addItems(list_comPort_available[::-1])
        self.__cbb_IUT_comport.setCurrentText(self.NOT_SELECTED)
        self.__cbb_IUT_comport.currentIndexChanged.connect(self.__CurrentIndexChanged)
        
        __label_cb_Reduced_TSPX_iut_private_address_interval = QLabel("Use reduced TSPX_iut_private_address_interval value")
        self.__cb_Reduced_TSPX_iut_private_address_interval = QCheckBox()
        self.__cb_Reduced_TSPX_iut_private_address_interval.setChecked(flag_Reduced_TSPX_iut_private_address_interval_default_value)
        
        self.separatorLine1 = QFrame()
        self.separatorLine1.setFrameShape(QFrame.HLine)
        self.separatorLine1.setFrameShadow(QFrame.Raised)
        
        __layout = QGridLayout(self)
        __layout.setRowStretch(0, 1)
        __layout.addWidget(__label_cbb_target_fw_ver, 1, 0)
        __layout.addWidget(self.__cbb_target_fw_ver, 1, 1)
        __layout.setRowStretch(2, 1)
        __layout.addWidget(__label_cbb_IUT_comport, 3, 0)
        __layout.addWidget(self.__cbb_IUT_comport, 3, 1)
        __layout.setRowStretch(4, 1)
        __layout.addWidget(self.separatorLine1, 5, 0, 1, 2)
        __layout.setRowStretch(6, 1)
        __layout.addWidget(__label_cb_Reduced_TSPX_iut_private_address_interval, 7, 0)
        __layout.addWidget(self.__cb_Reduced_TSPX_iut_private_address_interval, 7, 1, Qt.AlignRight)
        __layout.setRowStretch(8, 1)
        __layout.setRowStretch(9, 1)
        __layout.setRowStretch(10, 1)
        __layout.setRowStretch(11, 1)
        __layout.setRowStretch(12, 1)
        __layout.setRowStretch(13, 1)
        __layout.setRowStretch(14, 1)
        self.setLayout(__layout)

enter image description here

how do you handle blank lines having more control than what you get graphically?

0

There are 0 best solutions below