QTextEdit和QPlainTextEdit样式表中属性选择器不起作用的问题

来源:互联网 发布:湖北大学网络课程 编辑:程序博客网 时间:2024/06/05 19:44

QTextEdit和QPlainTextEdit样式表中属性选择器不起作用的问题。

描述:QPlainTextEdit中设置QPlaintTextEdit[readOnly="true"]{....}  QPlainTextEdit[readOnly="false"]{.....} 来为QPlainTextEdit在‘可编辑/不可编辑‘两种不同状态下设置不同的样式无效。

Qt文档中有这样一段话:

     If the value of the Qt property changes after the style sheet has been set, 
     it might be necessary to force a style sheet recomputation. 
     One way to achieve this is to unset the style sheet and set it again.

我的解决办法:
     若只想更新很多控件中其中一个控件的样式,可以:
     ui->frame->setStyle(ui->frame->style());
     或者
     ui->frame->setStyleSheet(ui->frame->styleSheet());
     或者

     ui->frame->setStyleSheet("");

0 0
原创粉丝点击