QGroupBox设置边框

一、setStyleSheet

QGroupBox {
    border-width:1px;   //线的粗细
   border-style:solid;
  border-color:lightGray;   //颜色,
  margin-top: 0.5ex;  //文字在方框中位置的偏离度
}
QGroupBox::title {
     subcontrol-origin: margin;
     subcontrol-position: top left;
   left:25px;       //线的偏离度
     margin-left: 0px;
     padding:0 1px;   //文字在方框中位置的偏离度
}
QGroupBox::title {
     subcontrol-origin: margin;
     position: relative;
     left: 12px;
}
ui->groupBox->setStyleSheet("background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #E0E0E0, stop: 1 #FFFFFF);"
                                " border-radius: 5px; margin-top: 1ex; ");//border: 2px solid gray;

 

转载于:https://www.cnblogs.com/wiessharling/archive/2013/05/10/3072009.html

你可能感兴趣的:(QGroupBox设置边框)