函数结构详细解析:
.addWidget()函数
addWidget(QWidget * widget, int fromRow, int fromColumn, int rowSpan, int columnSpan, Qt::Alignment alignment = 0)
QWidget * widget:需要添加的widget
int fromRow:所在行
int fromColumn:所在列
int rowSpan:所占行数
int columnSpan:所占列数
alignment:对齐方式
按5*5的方格理解
举例:
def initUi(self):
self.layout.addWidget(self.label_image,1,1,3,2)
self.layout.addWidget(self.button_search_image,1,3,1,2)
self.layout.addWidget(self.button_run,3,3,1,2)
self.layout.addWidget(self.label_predict_result,4,3,1,1)
self.layout.addWidget(self.label_predict_result_display,4,4,1,1)
self.layout.addWidget(self.label_predict_acc,5,3,1,1)
self.layout.addWidget(self.label_predict_acc_display,5,4,1,1)
self.button_search_image.clicked.connect(self.openimage)
self.button_run.clicked.connect(self.run)
self.setGeometry(300,300,300,300)
self.setWindowTitle('举个例子')
self.show()
按5*5的方格理解: