当前位置:网站首页>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
边栏推荐
- 改变线程状态的方法
- Regular expressions remove spaces at both ends
- B站713故障后的多活容灾建设|TakinTalks大咖分享
- 银行案例|Zabbix跨版本升级指南,4.2-6.0不香吗?
- Baoli food listed on Shanghai Stock Exchange: annual revenue of 1.578 billion, market value of 5.8 billion
- Summary of common methods of ArrayList
- 18. Text processing tool -grep
- 完美指南|如何使用 ODBC 进行无代理 Oracle 数据库监控?
- 从tidb实时同步到mysql 只能用 tidb binlog 工具吗?
- Detail throw and throws
猜你喜欢

Laboratory procedures and references of chloramphenicol acetate

What should I do if I can't see any tiles on SAP Fiori launchpad?

Overview of static inner classes and non static inner classes

Jesd204b debugging notes (practical version)

@Simple understanding and use of conditionalonproperty

multi-table query

ECCV2022 | RU&谷歌提出用CLIP进行zero-shot目标检测!

@Simple use of conditional

Baoli food listed on Shanghai Stock Exchange: annual revenue of 1.578 billion, market value of 5.8 billion

Error: slf4j: class path contains multiple slf4j bindings
随机推荐
初学者入门:使用WordPress搭建一个专属自己的博客
[nuxt 3] (XII) project directory structure 2
MySQL extensions
POJ1273 Drainage Ditches【最大流】【SAP】
Baoli food listed on Shanghai Stock Exchange: annual revenue of 1.578 billion, market value of 5.8 billion
SparkSubmit.main()方法提交外部参数,远程提交standalone集群任务
7-16 daily sword finger offer II 041. Average value of sliding window
500强企业如何提升研发效能?来看看行业专家怎么说!
JS true / false array conversion
[node+ts] build node+typescript project
2021-03-15
BSP video tutorial issue 21: easy one key implementation of serial port DMA variable length transceiver, support bare metal and RTOS, including MDK and IAR, which is more convenient than stm32cubemx (
粘制定位
Why do you need foreign keys?
[Nuxt 3] (十二) 项目目录结构 2
flinksql从Oracle同步数据到Doris,一共50几个字段,Oracle表中3000多万条
Will saffron become a safe and effective natural therapy for patients with arthritis?
2022 global Vocational Education Industry Development Report
Mixin\ plug in \scoped style
Article reproduction: srcnn