vendredi 21 mai 2021

I wanna set check box margin ? alignment

I made some Qdialog

when I execute code, the checkbox is not evenly aligned. as below image enter image description here

but I wanna like this,

enter image description here

here code,

thank you!!!

class SelectPay_Dialog2(Qdialog):

def __init__(self):
    super().__init__()  

    self.initUI()

def initUI(self):
    self.setGeometry(500, 200, 400, 200)
    self.setWindowTitle("Window")

    
    label1 = QLabel("test  : ") 
    label2 = QLabel("test  : ")
    label3 = QLabel("test : ")
    #
    label1.setFixedSize(80, 20)
    label2.setFixedSize(80, 20)
    label3.setFixedSize(80, 20)

   

    cb1 = QCheckBox('1week')
    cb2 = QCheckBox('2week')
    cb3 = QCheckBox('3week')
    cb4 = QCheckBox('4week')
    cb5 = QCheckBox('5week')
    cb6 = QCheckBox('6week')


    self.input_date_text1 = QLineEdit()  
    self.input_date_text2 = QLineEdit()
    self.input_date_text1.setFixedSize(100, 25)
    self.input_date_text2.setFixedSize(100, 25)
    self.input_date_text1.setReadOnly(True)
    self.input_date_text2.setReadOnly(True)




    layout = QGridLayout()
    layout.addWidget(label1, 0, 0)
    layout.addWidget(label2, 2, 0)
    layout.addWidget(label3, 1, 0)

    layout.addWidget(self.input_date_text1, 2, 1)
    layout.addWidget(self.input_date_text2, 2, 2)


    layout.addWidget(cb1, 1, 1 )
    layout.addWidget(cb2, 1, 2 )
    layout.addWidget(cb3, 1, 3 )
    layout.addWidget(cb4, 1, 4)
    layout.addWidget(cb5, 1, 5)


    self.setLayout(layout)



Aucun commentaire:

Enregistrer un commentaire