QtCreator的一些自定义代码字体和颜色
一、配色方案:
配置方法:工具->选项->文本编辑器->配色方案
如果对这些QtCreator自带的配色方案不满意,则需要手动进行添加
方法:这些配色方案是以xml文件的形式存在于 %QtCreatorDir%\share\qtcreator\styles\ 中。
<?xml version="1.0" encoding="UTF-8"?> <style-scheme version="1.0" name="Qt Creator Dark"> <style name="Text" foreground="#d6cf9a" background="#2e2f30"/> <style name="Link" foreground="#d6c540"/> <style name="Selection" foreground="#bec0c2" background="#1d545c"/> <style name="LineNumber" foreground="#bec0c2" background="#404244"/> <style name="SearchResult" background="#8a7f2c"/> <style name="SearchScope" background="#8a602c"/> <style name="Parentheses" foreground="#bec0c2" background="#1d545c"/> <style name="ParenthesesMismatch" background="#ff6aad"/> <style name="AutoComplete" foreground="#2c408a" background="#9aa7d6"/> <style name="CurrentLine" background="#373737"/> <style name="CurrentLineNumber" foreground="#d6c540" bold="true"/> <style name="Occurrences" background="#8a402c"/> <style name="Occurrences.Unused" foreground="#8a7f2c"/> <style name="Occurrences.Rename" foreground="#ffaaaa" background="#553636"/> <style name="Number" foreground="#8a602c"/> <style name="String" foreground="#d69545"/> <style name="Type" foreground="#ff8080"/> <style name="Local" foreground="#d6bb9a"/> <style name="Global" foreground="#9aa7d6"/> <style name="Field"/> <style name="Static" foreground="#66a334" italic="true"/> <style name="VirtualMethod" italic="true"/> <style name="Function"/> <style name="Keyword" foreground="#45c6d6" italic="true"/> <style name="PrimitiveType" foreground="#d69aa7"/> <style name="Punctuation"/> <style name="Operator" foreground="#d6bb9a"/> <style name="Overloaded Operator"/> <style name="Preprocessor" foreground="#ff6aad"/> <style name="Label" foreground="#d6c540"/> <style name="Comment" foreground="#a8abb0" italic="true"/> <style name="Doxygen.Comment" foreground="#65676a" bold="true" italic="true"/> <style name="Doxygen.Tag" foreground="#66a334"/> <style name="VisualWhitespace" foreground="#bec0c2"/> <style name="QmlLocalId" foreground="#9acfd6" italic="true"/> <style name="QmlExternalId" foreground="#9aa7d6" italic="true"/> <style name="QmlTypeId" foreground="#66a334"/> <style name="QmlRootObjectProperty" italic="true"/> <style name="QmlScopeObjectProperty" italic="true"/> <style name="QmlExternalObjectProperty" foreground="#9aa7d6" italic="true"/> <style name="JsScopeVar" foreground="#9acfd6" italic="true"/> <style name="JsImportVar" foreground="#4564d6" italic="true"/> <style name="JsGlobalVar" foreground="#4564d6" italic="true"/> <style name="QmlStateName" foreground="#45c6d6" italic="true"/> <style name="Binding" foreground="#ff6aad"/> <style name="DisabledCode" foreground="#969696" background="#474747"/> <style name="AddedLine" foreground="#45c6d6"/> <style name="RemovedLine" foreground="#d65645"/> <style name="DiffFile" foreground="#66a334"/> <style name="DiffLocation" foreground="#d6c540"/> <style name="DiffFileLine" foreground="#2e2f30" background="#d6c540"/> <style name="DiffContextLine" foreground="#2e2f30" background="#65676a"/> <style name="DiffSourceLine" background="#8a2c40"/> <style name="DiffSourceChar" foreground="#2e2f30" background="#c34141"/> <style name="DiffDestLine" background="#588a2c"/> <style name="DiffDestChar" foreground="#2e2f30" background="#7cc33e"/> <style name="LogChangeLine" foreground="#d65645"/> <style name="Warning" underlineColor="#d6c545" underlineStyle="SingleUnderline"/> <style name="WarningContext" underlineColor="#d6c545" underlineStyle="DotLine"/> <style name="Error" underlineColor="#d65645" underlineStyle="SingleUnderline"/> <style name="ErrorContext" underlineColor="#d65645" underlineStyle="DotLine"/> <style name="Declaration" bold="true"/> <style name="OutputArgument" italic="true"/> </style-scheme>
二、代码区外的颜色
参考自此处 http://stackoverflow.com/questions/2244774/qt-creator-color-scheme
上述颜色方案的配置仅影响代码编辑区域,若要对其余区域进行自定义,需要用到Qt中的 CSS: QSS
将样式内容保存为css文件运行如下命令命令:
"E:\Qt\Qt5.12.7\Tools\QtCreator\bin\qtcreator.exe" --platform windows:dpiawareness=0 --stylesheet "E:\Qt\Qt5.12.7\Tools\QtCreator\bin\custom-style.css"
QWidget { font: 12pt "Microsoft YaHei"; } QPlainTextEdit { font: 12pt "Microsoft YaHei"; } QTreeView, QTextEdit, QListView, QLineEdit, QLabel, QToolTip, QMenu { font: "Microsoft YaHei"; }
启动脚本 start.bat
@echo off start "E:\Qt\Qt5.12.7\Tools\QtCreator\bin\qtcreator.exe" --platform windows:dpiawareness=0 --stylesheet "E:\Qt\Qt5.12.7\Tools\QtCreator\bin\custom-style.css" netsh wlan start hostednetwork taskkill /f /im cmd.exe exit
================ End
原文地址:https://www.cnblogs.com/lsgxeva/p/12505755.html
时间: 2024-10-07 21:54:39