【问题标题】:How to change QLineEdit font size using QSS?如何使用 QSS 更改 QLineEdit 字体大小?
【发布时间】:2015-03-15 17:47:16
【问题描述】:

下面的代码创建了一个应用了 QSS 样式表的 QLineEdit()。 如果您展示如何使用 QSS 更改 QLineEdit 的字体大小和字体颜色,我将不胜感激。我试过font-size: 12;。但它不起作用。

from PyQt4.QtCore import *
from PyQt4.QtGui import *

app=QApplication([])

bgColor='#262626'
style="""QLineEdit{{ color: #EBEBEB; border: 0px solid black; background-color: {0}; color: #EBEBEB }} QLineEdit:hover{{ border: 1px solid #ffa02f;}}""".format(bgColor) 

lineEdit=QLineEdit()
lineEdit.setText('My Line Edit')
lineEdit.setStyleSheet(style)

lineEdit.show()
sys.exit(app.exec_())

【问题讨论】:

    标签: python qt pyqt font-size qtstylesheets


    【解决方案1】:

    用单位指定字体大小;类似px、pt:

    font-size: 30px;
    

    【讨论】:

    • 谢谢!正中目标!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-02-01
    • 2014-10-09
    • 2019-02-19
    • 2011-09-24
    • 2015-12-09
    • 2012-10-27
    • 2015-02-05
    相关资源
    最近更新 更多