qt学习之用qlabel制作假表格
1.设置ui排版,在网格布局中加入9个qlabel
2.设置文字,并且让其居中
ui->label_2->setAlignment(Qt::AlignCenter);
ui->label_3->setAlignment(Qt::AlignCenter);
ui->label_4->setAlignment(Qt::AlignCenter);
ui->label_5->setAlignment(Qt::AlignCenter);
ui->label_6->setAlignment(Qt::AlignCenter);
ui->label_7->setAlignment(Qt::AlignCenter);
ui->label_8->setAlignment(Qt::AlignCenter);
ui->label_9->setAlignment(Qt::AlignCenter);
ui->label_10->setAlignment(Qt::AlignCenter);
setStyleSheet(R"(
QLabel {
color: #4a6785; /* 淡蓝色文字 */
border: 1px solid #b7cbe0; /* 边框颜色 */
}
)");
3.注意网格间距要调整为0
4.结果展示