zoukankan      html  css  js  c++  java
  • Qt实现文本编辑器(自动补全,语法高亮)

    下载编译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);
    

    效果:

  • 相关阅读:
    Go反射
    Go_CSP并发模型
    Go_select
    Go计时器
    day9:vcp考试
    day8:vcp考试
    day7:vcp考试
    day6:vcp考试
    day5:vcp考试
    day4:vcp考试
  • 原文地址:https://www.cnblogs.com/tjhd/p/13889484.html
Copyright © 2011-2022 走看看