0


Qt Creator设置IDE的字体、颜色、主题样式

    Qt是一款开源的、跨平台的C++开发框架,支持Windows、Linux、Mac系统,从1995发布第一版以来,发展迅猛,最开始是用于Nokia手机的Symbian(塞班)系统和应用程序开发,现在是用于嵌入式软件、桌面软件(比如WPS、VirtualBox)、Android软件等开发,到2023年12月,其最新的版本已经更新到了v6.6。
    而Qt Creator是Qt的开源实现IDE,现在已经集成到了Qt.exe里,Qt Creator默认的颜色是白色,字体是跟随系统字体。它原来的白色太刺眼,系统字体对于编程有点古板。这里介绍Qt Creator的字体、颜色、主题样式设置,以Qt 5.14.2为例进行说明。

1 下载并安装微软雅黑字体

1.1 下载微软雅黑字体

    微软雅黑字体,分为Microsoft YaHei mono字体、Microsoft YaHei字体,即一个带mono,另一个不带mono。推荐使用带mono的,它字体等宽,颜色也好看。
    Microsoft YaHei mono字体地址: https://pan.baidu.com/s/1nG3m_plcfnrbNgksnep5_Q 提取码:in9h
    下载之后,将其解压,得到MSYHMONO.ttf文件,右击MSYHMONO.ttf文件 --》再点击"为所有用户"安装即可,如图(1)所示:

图(1) 安装微软雅黑mono字体

1.2 启用Microsoft YaHei mono字体

    点击QtCreator菜单栏上的[工具] --> 选项 --》
文本编辑器 --》字体 --》选中 Microsoft YaHei mono --》Apply

图(2) 点击Qt Creator工具栏上的[工具]-->选项

图(3) 在[文本编辑器] --》字体和颜色 --》选中"Microsoft YaHei Mono"

2 配置字体和颜色文件

2.1 编写vscode.xml

    vscode.xml是一个仿造vscode软件经典黑色的配置文件,代码区和工具栏,都是亮酷的黑色,如图(1)所示:

图(3) vscode的字体样式

    在D:\Qt\Qt5.14.2\Tools\QtCreator\share\qtcreator\styles目录,新建一个vscode.xml文件,将如下内容拷贝到vscode.xml;
    //D:\Qt\Qt5.14.2\Tools\QtCreator\share\qtcreator\styles\vscode.xml

<?xml version="1.0" encoding="UTF-8"?><style-schemeversion="1.0"name="VSCode"><stylename="Text"foreground="#9cdcfe"italic="false"background="#282c34"/><stylename="Link"/><stylename="Selection"background="#264f78"/><stylename="LineNumber"foreground="#858585"background="#1e1e1e"/><stylename="SearchResult"background="#333333"/><stylename="SearchScope"background="#1e1e1e"/><stylename="Parentheses"foreground="#dcdcaa"background="#343a40"/><stylename="CurrentLine"background="#707070"/><stylename="CurrentLineNumber"foreground="#c6c6c6"bold="true"/><stylename="Occurrences"background="#363636"/><stylename="Occurrences.Unused"foreground="#3b84b1"/><stylename="Occurrences.Rename"foreground="#ffaaaa"background="#553636"/><stylename="Number"foreground="#b5cea8"/><stylename="String"foreground="#ce9178"/><stylename="PrimitiveType"foreground="#569cd6"/><stylename="Type"foreground="#4ec9b0"/><stylename="Local"/><stylename="Field"/><stylename="Static"foreground="#569cd6"italic="false"/><stylename="VirtualMethod"italic="false"/><stylename="Function"foreground="#dcdcaa"italic="false"/><stylename="Keyword"foreground="#569cd6"/><stylename="Operator"foreground="#d4d4d4"/><stylename="Overloaded Operator"foreground="#dcdcaa"/><stylename="Preprocessor"foreground="#c586c0"/><stylename="Label"foreground="#569cd6"/><stylename="Comment"foreground="#6a9955"/><stylename="Doxygen.Comment"foreground="#6a9955"/><stylename="Doxygen.Tag"foreground="#00a0a0"/><stylename="VisualWhitespace"foreground="#c0c0c0"/><stylename="QmlLocalId"italic="false"/><stylename="QmlExternalId"foreground="#aaaaff"italic="false"/><stylename="QmlTypeId"foreground="#f3f351"/><stylename="QmlRootObjectProperty"italic="false"/><stylename="QmlScopeObjectProperty"italic="false"/><stylename="QmlExternalObjectProperty"foreground="#aaaaff"italic="false"/><stylename="JsScopeVar"foreground="#8888ff"italic="false"/><stylename="JsImportVar"foreground="#8888ff"italic="false"/><stylename="JsGlobalVar"foreground="#8888ff"italic="false"/><stylename="QmlStateName"italic="false"/><stylename="Binding"foreground="#ff5555"/><stylename="DisabledCode"foreground="#777777"background="#282c34"/><stylename="AddedLine"foreground="#55ffff"/><stylename="RemovedLine"foreground="#ff5555"/><stylename="DiffFile"foreground="#6a9955"/><stylename="DiffLocation"foreground="#ffff55"/><stylename="DiffFileLine"foreground="#000000"background="#d7d700"/><stylename="DiffContextLine"foreground="#000000"background="#8aaab6"/><stylename="DiffSourceLine"background="#8c2d2d"/><stylename="DiffSourceChar"foreground="#000000"background="#c34141"/><stylename="DiffDestLine"background="#2d8c2d"/><stylename="DiffDestChar"foreground="#000000"background="#41c341"/><stylename="Declaration"bold="false"/><stylename="Global"foreground="#9cdcfe"italic="false"/></style-scheme>

图(4) 在Qt的安装目录styles里,新建vscode.xml文件

2.2 启用VSCode字体样式

    点击Qt Creator菜单栏上的[工具] --> 选项 --》 文本编辑器 --》字体和颜色,选中"VSCode" --》Apply

图(5) 启用VScode字体样式

3 设置主题样式

3.1 新建oneDark.creatortheme主题文件

    Qt Creator左侧的项目浏览框、文件打开框、右下角的输出框,都由Theme控制,它们保存在D:\Qt\Qt5.14.2\Tools\QtCreator\share\qtcreator\themes目录。

图(6) theme主题,控制的区域

    在D:\Qt\Qt5.14.2\Tools\QtCreator\share\qtcreator\themes目录,新建一个oneDark.creatortheme文件,内容如下:
    //D:\Qt\Qt5.14.2\Tools\QtCreator\share\qtcreator\themes\oneDark.creatortheme

[General]
ThemeName=oneDark
PreferredStyles=Fusion
DefaultTextEditorColorScheme=oneDark.xml

[Palette]
shadowBackground=ff21252b
text=ffabb2bf
textDisabled=99abb2bf
textHighlighted=ffd7dae0
toolBarItem=ffabb2bf
toolBarItemDisabled=99abb2bf
fancyBarsNormalTextColor=ffabb2bf
fancyBarsBoldTextColor=ffabb2bf
hoverBackground=ff31363f
selectedBackground=ff3a3f4b
selectedBackgroundText=ffd7dae0
normalBackground=ff282c34
alternateBackground=ff31363f
error=ffe06c75
warning=ffe5c07b
success=ff98c379
message=ff61afef
splitter=ff181a1f
textColorLink=61afef
textColorLinkVisited=c678dd
backgroundColorDisabled=ff21252b

[Colors]

;DS controls theme START
DScontrolBackground=normalBackground
DScontrolOutline=splitter
DStextColor=text
DSdisabledTextColor=textDisabled
DSpanelBackground=ff454444
DShoverHighlight=hoverBackground
DScolumnBackground=ff363636
DSfocusEdit=normalBackground
DSfocusDrag=ff565656
DScontrolBackgroundPressed=selectedBackground
DScontrolBackgroundChecked=selectedBackground
DSinteraction=selectedBackground
DSsliderActiveTrack=ff7a7a7a
DSsliderInactiveTrack=ff4d4d4d
DSsliderHandle=ff4b5362
DSsliderActiveTrackHover=ff7f7f7f
DSsliderInactiveTrackHover=ff505050
DSsliderHandleHover=ff7a7a7a
DSsliderActiveTrackFocus=ffaaaaaa
DSsliderInactiveTrackFocus=ff7a7a7a
DSsliderHandleFocus=ff1d545c
DSerrorColor=error
DScontrolBackgroundDisabled=backgroundColorDisabled
DScontrolOutlineDisabled=ff4d4d4d
DStextColorDisabled=textDisabled
DStextSelectionColor=selectedBackground
DStextSelectedTextColor=selectedBackgroundText
DSscrollBarTrack=ff4d4d4d
DSscrollBarHandle=ff4b5362
DScontrolBackgroundInteraction=ff4d4d4d
DStranslationIndicatorBorder=splitter
DSsectionHeadBackground=alternateBackground
DSchangedStateText=message
DS3DAxisXColor=error
DS3DAxisYColor=success
DS3DAxisZColor=message
;DS controls theme END

BackgroundColorAlternate=alternateBackground
BackgroundColorDark=shadowBackground
BackgroundColorHover=hoverBackground
BackgroundColorNormal=normalBackground
BackgroundColorDisabled=backgroundColorDisabled
BackgroundColorSelected=selectedBackground
BadgeLabelBackgroundColorChecked=text
BadgeLabelBackgroundColorUnchecked=text
BadgeLabelTextColorChecked=normalBackground
BadgeLabelTextColorUnchecked=normalBackground
CanceledSearchTextColor=error
ComboBoxArrowColor=toolBarItem
ComboBoxArrowColorDisabled=toolBarItemDisabled
ComboBoxTextColor=fancyBarsNormalTextColor
DetailsButtonBackgroundColorHover=hoverBackground
DetailsWidgetBackgroundColor=shadowBackground
DockWidgetResizeHandleColor=splitter
DoubleTabWidget1stSeparatorColor=splitter
DoubleTabWidget1stTabActiveTextColor=text
DoubleTabWidget1stTabBackgroundColor=normalBackground
DoubleTabWidget1stTabInactiveTextColor=text
DoubleTabWidget2ndSeparatorColor=toolBarItemDisabled
DoubleTabWidget2ndTabActiveTextColor=text
DoubleTabWidget2ndTabBackgroundColor=selectedBackground
DoubleTabWidget2ndTabInactiveTextColor=text
EditorPlaceholderColor=shadowBackground
FancyToolBarSeparatorColor=toolBarItemDisabled
FancyTabBarBackgroundColor=shadowBackground
FancyTabBarSelectedBackgroundColor=selectedBackground
FancyTabWidgetDisabledSelectedTextColor=toolBarItemDisabled
FancyTabWidgetDisabledUnselectedTextColor=toolBarItemDisabled
FancyTabWidgetEnabledSelectedTextColor=fancyBarsBoldTextColor
FancyTabWidgetEnabledUnselectedTextColor=fancyBarsBoldTextColor
FancyToolButtonHoverColor=hoverBackground
FancyToolButtonSelectedColor=selectedBackground
FutureProgressBackgroundColor=shadowBackground
IconsBaseColor=toolBarItem
IconsDisabledColor=toolBarItemDisabled
IconsInfoColor=message
IconsInfoToolBarColor=message
IconsWarningColor=warning
IconsWarningToolBarColor=warning
IconsErrorColor=error
IconsErrorToolBarColor=error
IconsRunColor=success
IconsRunToolBarColor=success
IconsStopColor=error
IconsStopToolBarColor=error
IconsInterruptColor=message
IconsInterruptToolBarColor=message
IconsDebugColor=toolBarItem
IconsNavigationArrowsColor=warning
IconsBuildHammerHandleColor=b06112
IconsBuildHammerHeadColor=toolBarItem
IconsModeWelcomeActiveColor=success
IconsModeEditActiveColor=message
IconsModeDesignActiveColor=warning
IconsModeDebugActiveColor=message
IconsModeProjectActiveColor=success
IconsModeAnalyzeActiveColor=message
IconsModeHelpActiveColor=warning
IconsCodeModelKeywordColor=ff777777
IconsCodeModelClassColor=ffc0b550
IconsCodeModelStructColor=ff53b053
IconsCodeModelFunctionColor=ffd34373
IconsCodeModelVariableColor=ff2bbbcc
IconsCodeModelEnumColor=ffc0b550
IconsCodeModelMacroColor=ff476ba0
IconsCodeModelAttributeColor=ff316511
IconsCodeModelUniformColor=ff994899
IconsCodeModelVaryingColor=ffa08833
IconsCodeModelOverlayBackgroundColor=normalBackground
IconsCodeModelOverlayForegroundColor=text
InfoBarBackground=shadowBackground
InfoBarText=text
MenuBarEmptyAreaBackgroundColor=shadowBackground
MenuBarItemBackgroundColor=shadowBackground
MenuBarItemTextColorDisabled=textDisabled
MenuBarItemTextColorNormal=text
MenuItemTextColorDisabled=textDisabled
MenuItemTextColorNormal=text
MiniProjectTargetSelectorBackgroundColor=shadowBackground
MiniProjectTargetSelectorBorderColor=shadowBackground
MiniProjectTargetSelectorSummaryBackgroundColor=normalBackground
MiniProjectTargetSelectorTextColor=fancyBarsNormalTextColor
PanelStatusBarBackgroundColor=shadowBackground
PanelsWidgetSeparatorLineColor=splitter
PanelTextColorDark=text
PanelTextColorMid=text
PanelTextColorLight=textHighlighted
ProgressBarColorError=error
ProgressBarColorFinished=success
ProgressBarColorNormal=message
ProgressBarTitleColor=text
ProgressBarBackgroundColor=alternateBackground
SplitterColor=splitter
TextColorDisabled=textDisabled
TextColorError=error
TextColorHighlight=textHighlighted
TextColorHighlightBackground=hoverBackground
TextColorLink=textColorLink
TextColorLinkVisited=textColorLinkVisited
TextColorNormal=text
ToggleButtonBackgroundColor=shadowBackground
ToolBarBackgroundColor=shadowBackground
TreeViewArrowColorNormal=hoverBackground
TreeViewArrowColorSelected=text

OutputPanes_DebugTextColor=text
OutputPanes_ErrorMessageTextColor=error
OutputPanes_MessageOutput=message
OutputPanes_NormalMessageTextColor=text
OutputPanes_StdErrTextColor=error
OutputPanes_StdOutTextColor=text
OutputPanes_WarningMessageTextColor=warning
OutputPanes_TestPassTextColor=success
OutputPanes_TestFailTextColor=error
OutputPanes_TestXFailTextColor=error
OutputPanes_TestXPassTextColor=message
OutputPanes_TestSkipTextColor=message
OutputPanes_TestWarnTextColor=warning
OutputPanes_TestFatalTextColor=error
OutputPanes_TestDebugTextColor=text
OutputPaneButtonFlashColor=error
OutputPaneToggleButtonTextColorChecked=fancyBarsNormalTextColor
OutputPaneToggleButtonTextColorUnchecked=fancyBarsNormalTextColor

Debugger_LogWindow_LogInput=ff56b6c2
Debugger_LogWindow_LogStatus=message
Debugger_LogWindow_LogTime=error

Debugger_WatchItem_ValueNormal=text
Debugger_WatchItem_ValueInvalid=textDisabled
Debugger_WatchItem_ValueChanged=error

Debugger_Breakpoint_TextMarkColor=message

Welcome_TextColor=text
Welcome_ForegroundPrimaryColor=text
Welcome_ForegroundSecondaryColor=text
Welcome_BackgroundColor=normalBackground
Welcome_ButtonBackgroundColor=normalBackground
Welcome_DividerColor=splitter
Welcome_HoverColor=hoverBackground
Welcome_LinkColor=textColorLink
Welcome_DisabledLinkColor=textDisabled

Timeline_TextColor=text
Timeline_BackgroundColor1=normalBackground
Timeline_BackgroundColor2=shadowBackground
Timeline_DividerColor=splitter
Timeline_HighlightColor=selectedBackground
Timeline_PanelBackgroundColor=alternateBackground
Timeline_PanelHeaderColor=normalBackground
Timeline_HandleColor=ff4b5362
Timeline_RangeColor=selectedBackground

VcsBase_FileStatusUnknown_TextColor=text
VcsBase_FileAdded_TextColor=success
VcsBase_FileModified_TextColor=warning
VcsBase_FileDeleted_TextColor=error
VcsBase_FileRenamed_TextColor=message
VcsBase_FileUnmerged_TextColor=error

Bookmarks_TextMarkColor=message

TextEditor_SearchResult_ScrollBarColor=success
TextEditor_CurrentLine_ScrollBarColor=message

ProjectExplorer_TaskError_TextMarkColor=error
ProjectExplorer_TaskWarn_TextMarkColor=warning

CodeModel_Error_TextMarkColor=error
CodeModel_Warning_TextMarkColor=warning

QmlDesigner_BackgroundColor=normalBackground
QmlDesigner_HighlightColor=selectedBackground
QmlDesigner_FormEditorSelectionColor=message
QmlDesigner_FormEditorForegroundColor=normalBackground
QmlDesigner_BackgroundColorDarkAlternate=shadowBackground
QmlDesigner_BackgroundColorDarker=splitter
QmlDesigner_BorderColor=splitter
QmlDesigner_ButtonColor=normalBackground
QmlDesigner_TabDark=shadowBackground
QmlDesigner_TabLight=text
QmlDesigner_FormeditorBackgroundColor=normalBackground
QmlDesigner_AlternateBackgroundColor=alternateBackground
QmlDesigner_ScrollBarHandleColor=ff4b5362

PaletteWindow=shadowBackground
PaletteWindowText=text
PaletteBase=normalBackground
PaletteAlternateBase=alternateBackground
PaletteButton=shadowBackground
PaletteBrightText=error
PaletteText=text
PaletteButtonText=text
PaletteButtonTextDisabled=textDisabled
PaletteToolTipBase=hoverBackground
PaletteHighlight=selectedBackground
PaletteDark=shadowBackground
PaletteHighlightedText=selectedBackgroundText
PaletteToolTipText=text
PaletteLink=textColorLink
PaletteLinkVisited=textColorLinkVisited
PaletteWindowDisabled=backgroundColorDisabled
PaletteWindowTextDisabled=textDisabled
PaletteBaseDisabled=backgroundColorDisabled
PaletteTextDisabled=textDisabled

[Flags]
ComboBoxDrawTextShadow=false
DerivePaletteFromTheme=true
DrawIndicatorBranch=true
DrawSearchResultWidgetFrame=false
DrawTargetSelectorBottom=false
DrawToolBarHighlights=false
DrawToolBarBorders=false
ApplyThemePaletteGlobally=true
FlatToolBars=true
FlatSideBarIcons=true
FlatProjectsMode=true
FlatMenuBar=true
ToolBarIconShadow=true
WindowColorAsBase=true
DarkUserInterface=true

[Gradients]
DetailsWidgetHeaderGradient\1\color=normalBackground
DetailsWidgetHeaderGradient\1\pos=1
DetailsWidgetHeaderGradient\size=1

    如图(7)所示:

图(7) 在Qt的themes目录,创建oneDark.creatortheme文件

3.2 启用该主题

    打开QtCreator --》点击菜单栏上的[工具] --> 选项 --》 环境 --》Interface --> Theme 选择:oneDark --》Apply,如图(8)所示:

图(8) 启用oneDark主题

4 重启Qt Creator

    Qt Creator设置在自身的字体、颜色、主题样式之后,需要手动重启一下Qt Creator,即把Qt Creator先关闭后打开,就是重启Qt Creator。
    效果如下:

图(9) Qt Creator变成了酷黑的IDE

5 Qt Creator字体与主题文件

    Qt Creator字体与主题文件: https://pan.baidu.com/s/1xAxDVU4JVbEuLVUvZleijA 提取码:hsst

标签: qt ide 开发语言

本文转载自: https://blog.csdn.net/sanqima/article/details/134891360
版权归原作者 sanqima 所有, 如有侵权,请联系我们删除。

“Qt Creator设置IDE的字体、颜色、主题样式”的评论:

还没有评论