设置图片居中、居左、居右
QLabel{color:white; /* 字体颜色 */padding-left: 12px; /* 字体居右侧12px*/font-weight:bold; /* 加粗 */margin-right: 10px; /* 显示内容距label右侧距离为 10px */background-image:url(:/result.png); /* 背景图片*/background-repeat:no-repeat; /* 图片不重复*/background-position:right; /* 图片居右*/}
设置边框
/*QLabel 默认无边框,需要使用setFrameShape开启边框,并通过stylesheet设置边框宽度(因为默认是0)*/ui->label->setFrameShape (QFrame::Box);ui->label->setStyleSheet("border-width: 1px;border-style: solid;border-color: rgb(255, 170, 0);");
