当前位置:网站首页>Qt优秀开源项目之十三:QScintilla
Qt优秀开源项目之十三:QScintilla
2022-07-27 12:48:00 【草上爬】
Scintilla是一个免费、跨平台、支持语法高亮的编辑控件。它完整支持源代码的编辑和调试,包括语法高亮、错误指示、自动补全(code completion)和函数提示(call tips)。详细的介绍可参考:https://www.scintilla.org/
毫无疑问,Notepad++是最出名的基于Scintilla的开源编辑器,它完全用C++实现

而QScintilla是Scintilla在QT上的移植,使用该库可以更为方便的开发Qt程序
一.下载
QScintilla的官网:https://qscintilla.com/
下载地址:Riverbank Computing | Download
注意:有多个版本,而2.12及其以后的版本,不再支持Qt4和Qt5了,所以源码中没有QT4QT5这个目录了。这里我下载的是2.11.6这个版本。这里我使用的QT版本是 Qt 5.12.2。下载完成后解压,其目录结构如下:
| 目录名 | 用途 |
|---|---|
| Qt4Qt5 | 编译文件夹,生成对应的DLL文件 |
| designer-Qt4Qt5 | 相关的设计师插件的编译文件夹 |
| example-Qt4Qt5 | 简单的示例文件夹 |
| doc | 使用Doxygen生成的帮助文档 |
| lexers | 已实现的各语法分析器 |
| ... | ... |
本文只演示如何编译生成dll,关于Qt Designer插件的编译,详见:QScintilla的安装及简介
二.编译和测试
打开Qt4Qt5文件夹中的qscintilla.pro文件直接编译即可,没任何报错,这里以debug版本为例,编译完成后,会在debug目录中生成qscintilla2_qt5d.lib和qscintilla2_qt5d.dll文件
测试可以直接使用example-Qt4Qt5文件夹中的application工程,但是得对application.pro文件稍作修改,改后的文件如下所示:
QT += core gui widgets
CONFIG += qscintilla2
HEADERS = mainwindow.h
SOURCES = main.cpp mainwindow.cpp
RESOURCES = application.qrc
INCLUDEPATH += ../Qt4Qt5
LIBS += qscintilla2_qt5d.lib因为application工程中用到了Qt4Qt5/Qsci中的头文件,因此需要将Qt4Qt5目录包含到INCLUDEPATH中
然后将之前编译好的qscintilla2_qt5d.lib拷贝到example-Qt4Qt5中
这样就能正常编译application工程了,要运行的话,还得将qscintilla2_qt5d.dll拷贝到application.exe所在目录中
运行时,如下所示:

三.类的层次结构

图片来自:https://qscintilla.com/#editor
1.最基本的类就是QSciScintillaBase,它是⽂本编辑器的基类,该类偏底层,通常不直接使用。QScintilla库提供了⼀个上层⼦类QSciScintlla ,它就是⽂本编辑器类,其内有许多类似于Qt的API 。如果该类缺少所需的某些⾮常具体的功能,此时可以继承其⽗类QSciScintillaBase。
2.语法高亮显示的对象称之为词法分析器。创建并配置这样的词法分析器对象后,只需要将其应用到⽂本编辑器(QSciScintilla对象)中即可。关于词法分析器的实现,QScintilla提供了QSciLexer类,该类是⼀个抽象类,因此在创建对象之前,需要对其进行子类化。
3.⼀个好的⽂本编辑器提供的不仅仅是需要语法的高亮显示,还需要有函数参数提示和自动补全等功能。这些功能都存在于QSciAPI类中。只需要从该类创建⼀个实例,并将其应用到QSciLexer对象中即可。而其父类是一个抽象类,类名为QSciAbstractAPIs。
更多内容可参考官方文档
原文链接:https://blog.csdn.net/caoshangpa/article/details/125974273
边栏推荐
- Gartner 权威预测未来4年网络安全的8大发展趋势
- 正则表达式去除两端空格
- js日期时间格式化(年月日、时分秒、星期、季度、获取时间差、日期与时间戳转换的功能)
- Laboratory procedures and references of chloramphenicol acetate
- Jesd204b debugging notes (practical version)
- Distributed system architecture theory and components
- MySQL extensions
- 固定定位
- Why do you need foreign keys?
- feign client三个客户端的自动装配
猜你喜欢
QT | qcheckbox of control

Summary of common methods of ArrayList

Xposed+FDex2 app脱壳 (黑猫投诉app脱壳)

Sff1004-mhchxm diode sff1004

Gan: generate adversarial networks

Will saffron become a safe and effective natural therapy for patients with arthritis?

The sparksubmit. Main () method submits external parameters and remotely submits the standalone cluster task

How can the top 500 enterprises improve their R & D efficiency? Let's see what industry experts say!

500强企业如何提升研发效能?来看看行业专家怎么说!

Detail try catch finally
随机推荐
图标字体
Feign的整体流程
flinksql从Oracle同步数据到Doris,一共50几个字段,Oracle表中3000多万条
7-16 daily sword finger offer II 041. Average value of sliding window
Four characteristics of transactions (acid):
2021-03-15
Poj1548 robots [bipartite graph minimum path coverage]
Antd's tool function getprefixcls gets the public prefix
Xposed+FDex2 app脱壳 (黑猫投诉app脱壳)
[nuxt 3] (XII) project directory structure 2
feign client三个客户端的自动装配
C program debugging and exception handling (try catch)
固定定位
592. Fraction addition and subtraction: introduction to expression calculation
Laboratory procedures and references of chloramphenicol acetate
「游戏引擎 浅入浅出」4.1 Unity Shader和OpenGL Shader
Error: the source of the existing CacheManager is: urlconfigurationsource
Application parameters of Southern biotech HRP labeled avidin avidin avidin
PySide6/PyQt开发经验总结(2) - 设置快捷键
Plus版SBOM:流水线物料清单PBOM