[QScintilla] Autocompletion

Henk Nep henknep4 at gmail.com
Fri Aug 21 10:19:10 BST 2015


Hi Phil,

Thanks for responding, see simple example below:

main.cpp
------------
#include <QApplication>
#include "mainwindow.h"

int main(int argc, char *argv[])
{
     QApplication app(argc, argv);
     MainWindow mainWin;
     mainWin.show();
     return app.exec();
}

mainwindow.cpp
----------------------
#include <Qsci/qsciscintilla.h>
#include "mainwindow.h"

MainWindow::MainWindow()
{
     textEdit = new QsciScintilla;
     setCentralWidget(textEdit);

     QsciLexerCPP *lexer = new QsciLexerCPP();
     lexer->setDefaultFont(textEdit->font());
     lexer->setFoldComments(true);

     textEdit->setAutoCompletionSource(QsciScintilla::AcsAPIs);
     textEdit->setAutoCompletionThreshold(3);
textEdit->setAutoCompletionUseSingle(QsciScintilla::AcusNever);
     api = new QsciAPIs(lexer);
     api->load("test.api");
     api->prepare();
     textEdit->setLexer(lexer);
}

mainwindow.h
-------------------
#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QMainWindow>
#include <Qsci/qsciscintilla.h>
#include <Qsci/qscilexercpp.h>
#include <Qsci/qsciapis.h>

class QsciScintilla;

class MainWindow : public QMainWindow
{
public:
     MainWindow();
private:
     QsciScintilla *textEdit;
     QsciAPIs *api;
};

#endif

test.api
----------
test1(double,int,int) Extra info
test2(double)
test3(const char *s, int)

application.pro
--------------------
QT       += core gui

greaterThan(QT_MAJOR_VERSION, 4): QT += widgets

TARGET = testwindows
TEMPLATE = app
SOURCES += main.cpp\
         mainwindow.cpp
HEADERS  += mainwindow.h
win32:CONFIG(release, debug|release): LIBS += -LH:/Qt/5.4/msvc2013/lib/ 
-lqscintilla2
else:win32:CONFIG(debug, debug|release): LIBS += 
-LH:/Qt/5.4/msvc2013/lib/ -lqscintilla2d
INCLUDEPATH += H:/Qt/5.4/msvc2013/include
DEPENDPATH += H:/Qt/5.4/msvc2013/include

I have also created a small gotomeeting video clip if you are interested,

Thanks,
Henk.

On 20/08/2015 22:55, Phil Thompson wrote:
> On 20 Aug 2015, at 8:29 pm, Henk Nep <henknep4 at gmail.com> wrote:
>> Hi All,
>>
>> I have added autocompletion which seems to be working fine except for a few niggles. If I type in one of the keywords followed by an opening bracket then nothing happens, however, if I delete the bracket and retype it again the autocompletion kicks in. Similarly, if I type in a few characters followed by hitting the TAB key then autocompletion works fine. Is this a known issues?
> Impossible to say. Please provide a short, complete example that demonstrates the problem.
>
>> I also noticed that the autocompletion window is always about 10 lines deep even if only 1 keyword is offered, is there a setting to reduce the window size?
> That is implemented in the underlying Scintilla code.
>
> Phil



More information about the QScintilla mailing list