Qt stylesheet 点滴

Qt stylesheet 点滴

没学过 javascript,学习 Qt Script 有挺大难度。没学过 CSS,学习 Qt StyleSheet 有挺大难度。

不过幸好,Qt 的文档做得非常好。直接看 Qt Manual 就能解决大多数问题(哦,好吧,至少能用来回答网友问题)

实例一

csdn 的 Qt 板块有网友问:

QLineEdit密码框的显示问题?
m_edit->setEchoMode (QLineEdit::Password)设置了以后,输入的字符串都变成了实心大圆黑点。

我想它变成一般看到的*,应如何做呢?

翻到 stylesheet-reference,一切都很直接:

QLineEdit

Support the box model.
The color and background of the selected item is styled using selection-color and selection-background-color respectively.

The password character can be styled using the lineedit-password-character property.

答案就简单了:

lineEdit->setStyleSheet("lineedit-password-character: 42");实例二

qtcn 上有网友问:

急急急!!!困扰一天的QDockWidget!
QDockWidget 与标题栏中间总是有这么一条灰色的 细带;如图所示,怎么去掉啊!!!!哎

看到这种问题比较无奈,必须通过反问来搞清楚提问者问得的具体是什么

这儿提到是 QMainWindow的的 dockwidet 和 centralwidget 边界间的那点空间,是用来通过鼠标拖拽控制 dockwidget 的大小的。

同样,翻到 stylesheet-reference,一切都很直接:

Supports styling of the separator

The separator in a QMainWindow when using QDockWidget is styled using the ::separator subcontrol.

只要看一眼manual,答案也就很简单了

w.setStyleSheet("QMainWindow::separator{width: 0;} ")参考
  • http://doc.qt.nokia.com/4.7/stylesheet-reference.html

  • http://doc.qt.nokia.com/4.7/stylesheet-examples.html


你可能感兴趣的:(Qt stylesheet 点滴)