• 5648阅读
  • 2回复

关于QGroupBox的问题,请高手指点 [复制链接]

上一主题 下一主题
离线cllssg
 

只看楼主 倒序阅读 楼主  发表于: 2014-03-11
我想改变QGroupBox控件的边线颜色,用的下面的语句
ui->groupBox->setStyleSheet("QGroupBox{border:1px solid red}");
边线的颜色是变化了,但是又出现了新问题,就是字体到了变线的下方,在垂直面上怎么也居中不了,水平可以居中,请高手给指点!谢谢,

离线realfan

只看该作者 1楼 发表于: 2014-03-11
也遇到过,设了border后,字就沉下来了。尚未解决。
离线lonelyfancy

只看该作者 2楼 发表于: 2014-03-15
官方文档:

Customizing QGroupBox

Let us look at an example that moves the QGroupBox's title to the center.

QGroupBox {
    background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,
                                      stop: 0 #E0E0E0, stop: 1 #FFFFFF);
    border: 2px solid gray;
    border-radius: 5px;
    margin-top: 1ex; /* leave space at the top for the title */
}

QGroupBox::title {
    subcontrol-origin: margin;
    subcontrol-position: top center; /* position at the top center */
    padding: 0 3px;
    background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,
                                      stop: 0 #FF0ECE, stop: 1 #FFFFFF);
}
For a checkable QGroupBox, use the {#indicator-sub}{::indicator} subcontrol and style it exactly like a QCheckBox (i.e)

QGroupBox::indicator {
    width: 13px;
    height: 13px;
}

QGroupBox::indicator:unchecked {
    image: url(:/images/checkbox_unchecked.png);
}

/* proceed with styling just like QCheckBox */
快速回复
限100 字节
 
上一个 下一个