QtCreator的一些自定义代码字体和颜色
来源:互联网 发布:易语言钩子注入源码 编辑:程序博客网 时间:2024/05/20 23:37
本文非完全原创,属归纳和总结,发文于此,仅望于人有益
windows平台,仅供参考一、配色方案:
配置方法:工具->选项->文本编辑器->配色方案
如果对这些QtCreator自带的配色方案不满意,则需要手动进行添加
方法:
这些配色方案是以xml文件的形式存在于%QtCreatorDir%\share\qtcreator\styles\中的。
以下是一个vs风格的颜色方案
上述代码中红色部分即为QtCreator颜色方案下拉菜单中的方案名称
来自
http://gurumeditation.org/index.php/archives/64
http://gurumeditation.org/files/VisualStudio.xml
http://gurumeditation.org/files/VisualStudio.xml
<!-- Thanks for visiting http://gurumeditation.org --> <style-scheme version="1.0" name="VisualStudio"> <style name="AddedLine" foreground="#00aa00"/> <style name="Comment" foreground="#008000"/> <style name="CurrentLine" foreground="#000000"/> <style name="CurrentLineNumber" foreground="#808080" bold="true"/> <style name="DiffFile" foreground="#000080"/> <style name="DiffLocation" foreground="#0000ff"/> <style name="DisabledCode" foreground="#000000" background="#efefef"/> <style name="Doxygen.Comment" foreground="#000080"/> <style name="Doxygen.Tag" foreground="#0000ff"/> <style name="Keyword" foreground="#0000ff"/> <style name="Label" foreground="#000000"/> <style name="LineNumber" foreground="#2b91af" background="#ffffff"/> <style name="Link" foreground="#0000ff"/> <style name="Number" foreground="#000000"/> <style name="Occurrences" foreground="#000000" background="#dcdcdc"/> <style name="Occurrences.Rename" foreground="#000000" background="#ffc8c8"/> <style name="Occurrences.Unused" foreground="#c0c0c0"/> <style name="Operator" foreground="#000000"/> <style name="Parentheses" foreground="#000000" bold="true"/> <style name="Preprocessor" foreground="#0000ff"/> <style name="RemovedLine" foreground="#ff0000"/> <style name="SearchResult" foreground="#000000" background="#ffef0b"/> <style name="SearchScope" foreground="#000000" background="#ffe8d5"/> <style name="Selection" foreground="#ffffff" background="#2b6ac5"/> <style name="String" foreground="#a31515"/> <style name="Text" foreground="#000000" background="#ffffff"/> <style name="Type" foreground="#0000ff"/> <style name="VisualWhitespace" foreground="#c0c0c0"/> </style-scheme>
上述代码中红色部分即为QtCreator颜色方案下拉菜单中的方案名称
另一个颜色方案
来自http://qt-project.org/forums/viewthread/7680 <?xml version="1.0" encoding="UTF-8"?> <style-scheme version="1.0" name="MyDarkTheme"> <style name="AddedLine" foreground="#359f9f"/> <style name="Comment" foreground="#2d9a9e"/> <style name="CurrentLine" background="#232323"/> <style name="CurrentLineNumber" foreground="#aaaaaa" bold="true"/> <style name="DiffFile" foreground="#349e34"/> <style name="DiffLocation" foreground="#89892d"/> <style name="DisabledCode" foreground="#777777" background="#222222"/> <style name="Doxygen.Comment" foreground="#3dbbbb"/> <style name="Doxygen.Tag" foreground="#00a0a0"/> <style name="Field" foreground="#618f5c"/> <style name="Keyword" foreground="#acac39"/> <style name="Label" foreground="#bfbf3f"/> <style name="LineNumber" foreground="#888888" background="#232323"/> <style name="Link" foreground="#0041c4"/> <style name="Local" foreground="#696969"/> <style name="Number" foreground="#8393c0"/> <style name="Occurrences" background="#363636"/> <style name="Occurrences.Rename" foreground="#ffaaaa" background="#553636"/> <style name="Occurrences.Unused" foreground="#c0c0c0"/> <style name="Operator" foreground="#aaaaaa"/> <style name="Parentheses" foreground="#ff5555" background="#333333"/> <style name="Preprocessor" foreground="#917bbc"/> <style name="RemovedLine" foreground="#b43c3c"/> <style name="SearchResult" background="#555500"/> <style name="SearchScope" background="#222200"/> <style name="Selection" foreground="#000000" background="#aaaaaa"/> <style name="Static" foreground="#a69829"/> <style name="String" foreground="#485abe"/> <style name="Text" foreground="#a1a1a1" background="#000000"/> <style name="Type" foreground="#317f13"/> <style name="VirtualMethod" foreground="#a69174" italic="true"/> <style name="VisualWhitespace" foreground="#c0c0c0"/> </style-scheme>
其中规则并不难,稍加学习理解即可以做出适合自己的颜色方案。二、代码区外的颜色
参考自此处http://stackoverflow.com/questions/2244774/qt-creator-color-scheme
上述颜色方案的配置仅影响代码编辑区域,若要对其余区域进行自定义,需要用到Qt中的CSS:QSS
一个可用的配置文件如下
QMainWindow, QAbstractItemView, QTreeView::branch, QTabBar::tab{ color: #EAEAEA; background: #333333; font-size: 9pt; } QAbstractItemView::item:selected { color: #EAEAEA; background-color: #151515; } QScrollBar { border: none; background: #494949; height: 6px; width: 6px; margin: 0px; } QScrollBar::handle{ background: #DBDBDB; min-width: 20px; min-height: 20px; } QScrollBar::add-line, QScrollBar::sub-line { background: none; border: none; } QScrollBar::add-page, QScrollBar::sub-page { background: none; } QTreeView::branch:closed:adjoins-item:has-children { background: solid #777777; margin: 6px; height: 6px; width: 6px; border-radius: 3px; } QTabBar::tab:selected { font: bold; border-color: #9B9B9B; border-bottom-color: #C2C7CB; } QTabBar::tab:!selected { margin-top: 2px; } QHeaderView::section { background-color: qlineargradient(x1:0, y1:0, x2:0, y2:1, stop:0 #616161, stop: 0.5 #505050, stop: 0.6 #434343, stop:1 #656565); color: white; padding-left: 4px; border: 1px solid #6c6c6c; } QToolBar { border-style: solid; border-style: outset; color: #EAEAEA; background: #333333; font-size: 9pt; }
将上述内容保存为css文件运行如下命令命令:
qtcreator.exe -stylesheet yourconfig.css
从如上两篇文章中可以获得更多QSS的知识: Qt Style Sheets Reference, Qt Style Sheets Examples .Qt助手好像带有这两篇文章。
qtcreator.exe -stylesheet yourconfig.css
从如上两篇文章中可以获得更多QSS的知识: Qt Style Sheets Reference, Qt Style Sheets Examples .Qt助手好像带有这两篇文章。
- QtCreator的一些自定义代码字体和颜色
- QtCreator的一些自定义
- 自定义TabBarItem的字体颜色和大小
- 一些字体的颜色
- 自定义actionSheet 字体和颜色
- UISegmentedControl自定义背景颜色和字体颜色
- 自定义 placehoder 的字体颜色
- 自定义UITableView的Section 的 title 的字体 和颜色
- 自定义uialertview的字体和大小颜色等
- 自定义系统Tabbar选择后的图片和字体颜色
- 关于android自定义字体颜色和点击改变字体颜色
- 改变vs2005中代码字体的大小和颜色
- 如何更改Android Studio的代码字体和颜色
- UITableView自定义分区和自定义字母索引(包括自定义索引的字体和颜色)
- AS 自定义主题字体颜色和背景
- Xcode 6 技巧:自定义字体和颜色, 矢量图像,代码片段以及其他
- 设置UITableView Section的背景颜色和字体颜色-自定义Section
- IOS_设置UITableView Section的背景颜色和字体颜色(自定义section布局)
- kinect 人脸跟踪坐标问题
- iostat分析IO性能
- C语言实现一个FIBONACCI数发生器
- windows下wxPython开发环境安装与配置
- Qt程序退出断言问题
- QtCreator的一些自定义代码字体和颜色
- 程序员的职业规划
- yiqicms 产品列表,一级栏目和二级栏目拥有不同样式的解决方案
- DNS负载均衡技术
- oracle分页查询
- Error creating bean with name 'sessionFactory' defined in class path resource [spring/applicationCon
- mysql_ubuntu服务器上mysql客户端phpmyadmin 与Navicat的配置
- imshow,imagesc,image区别
- swprintf() — Format and Write Wide Characters to Buffer