下载编译qscintilla2_qt5.lib
Qscitinlla下载:https://riverbankcomputing.com/software/qscintilla/download
在Qt4Qt5目录中用QtCreator打开qscintilla.pro文件,分别编译release与debug版的qscintilla2_qt5.lib与qscintilla2_qt5d.lib
使用
1,把Qt4Qt5目录中的Qsci目录拷贝到要使用的工程源码目录,我的:app/source/Qsci
2,app.pro添加
INCLUDEPATH += ./source
# release
# LIBS += -L./Lib -lqscintilla2_qt5
# debug
LIBS += -L./Lib -lqscintilla2_qt5d
3,使用
#include "Qsci/qsciscintilla.h"
#include "Qsci/qscilexerpython.h"
#include "Qsci/qsciapis.h"
QsciScintilla* editor = new QsciScintilla;
QsciLexerPython* textLexer = new QsciLexerPython;
editor -> setLexer(textLexer);
editor -> setMarginType(0, QsciScintilla::NumberMargin);
editor -> setMarginLineNumbers(0, true);
editor -> setMarginWidth(0, 30);
QsciAPIs* apis = new QsciAPIs(textLexer);
apis -> add(QString("import"));
apis -> prepare();
editor -> setAutoCompletionSource(QsciScintilla::AcsAll);
editor -> setAutoCompletionCaseSensitivity(true);
editor -> setAutoCompletionThreshold(1);
editor -> SendScintilla(QsciScintilla::SCI_SETCODEPAGE, QsciScintilla::SC_CP_UTF8);
QVBoxLayout* leftLayout = new QVBoxLayout;
leftLayout -> addWidget(editor);
效果: