关于Qt控制中边框的显示的一些设置(完善中)

来源:互联网 发布:数控机床plc编程 编辑:程序博客网 时间:2024/06/11 01:20

1,可以通过指定类型来选择一类控件进行设置:

QLineEdit{

background-color: rgb(255, 255, 255);
border-radius:8px;
border-color: rgb(0, 0, 0);
border-style:solid;
border-width:3px;

}

但是如果父窗口是QWidget类型,而子类中是Qlabel,现在想设置QWidget的边框,而子类的QLabel不受影响,baidu中

2,关于设置QRradioButton选择圈大小的问题:

QRadioButton::indicator:unchecked {

     border-image: url(:/res/xxx.png);
 }
QRadioButton::indicator {
     width: 30px;
     height:30px;
 }
QRadioButton::indicator:checked {
     border-image: url(:/res/xxx.png);
 }

这样可以设置选择圈的大小和图片。

3,设置QLineEdit的格式:

    QIntValidator *intValidator = new QIntValidator(0,9999,this);
    ui->mLineEdit->setValidator(intValidator);

    QDoubleValidator* aValidator = new QDoubleValidator(9.1,9.9,
                                         5,this);   
  ui->mLineEdit->setValidator(aValidator); //设置输入范围

  ui->mLineEdit->setMaxLength(13); //设置输入长度

ui->mLineEdit->setText(QString("%1").arg(plucode,4,10,QChar('0'))); //设置输入格式不足补零
        

0 0
原创粉丝点击