Results 1 to 6 of 6

Thread: Code Completion in QScintilla

  1. #1

    Default Code Completion in QScintilla

    Hi, I work on ubuntu and I am developing a simple IDE to edit ActionScript projects, I am new in this world of QScintilla but I have traying since some days ago how to implement the Code Completion with QScintilla but have no results yet. I don't know how to do it. So Please if somebody can help me with a little piece of code, some example, I will appreciate it very, very much. I'm going to put a little code that I have tried but isn't work. Please help me.

    my useless code

    I have a class CTextEdit inherit from QsciScintilla with this method

    void CTextEdit::testTextModified(){

    QString text = this->text();
    if(text[text.length()-1] == '.')
    {
    QStringList list; list << "aaaa";
    list << "bbb";
    list << "cc";
    this->showUserList(1,list);
    }
    }

    and in other place I connect the CTextEdit*textEdit = new CTextEdit in this way

    connect(textEdit, SIGNAL(textChanged()), this, SLOT(testTextModified()));

    The connection works and testTextModified() run. But nothing about the completion. Please help me with some example.

  2. #2
    Join Date
    Jan 2006
    Location
    travelling
    Posts
    1,116
    Thanks
    8
    Thanked 127 Times in 121 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Code Completion in QScintilla

    There are already code-completion facilities in QScintilla that can be turned on easily (read the docs....) but they won't work unless a lexer (i.e. syntax highlighter with more general purpose...) is set to the editor. For instance :
    Qt Code:
    1. setLexer(new QsciLexerCPP);
    To copy to clipboard, switch view to plain text mode 
    If your language what are Action Script BTW?) is not supported by the available lexers you'll have to write one before being able to work with code completion...

    Hope this helps. (Yet I don't recommend using QScintilla if you're looking for flexibility )
    Current Qt projects : QCodeEdit, RotiDeCode

  3. #3

    Default Re: Code Completion in QScintilla

    Hi, thanks for your reply, as I said I am a little new with QScintilla (and Scintilla), I would like to get the full code completion of QScintilla but is just that I don't know how, I don't have a good documentation, and examples to do that. I really don't understand it. That's why I tried a simple way, but doesn't work. If you could help me please, I really need it.

    I get from my compiler all I need to put in the ListBox of the code completion, is just that I don't know how. I mean, my compiler, do all the work, and give me all I need, I just want to add to the code-completion. Anyway if you can help me with the full auto-completion. Tell me where I can get the information I need, anything will by useful. Thanks again.

  4. #4
    Join Date
    Jan 2006
    Location
    travelling
    Posts
    1,116
    Thanks
    8
    Thanked 127 Times in 121 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Code Completion in QScintilla

    Quote Originally Posted by jpjimenez View Post
    I get from my compiler all I need to put in the ListBox of the code completion
    Then using QScintilla may not be needed... You can simply use a QCompleter on a QTextEdit (there's an example of such a combination in Qt)

    Quote Originally Posted by jpjimenez View Post
    Tell me where I can get the information I need, anything will by useful.
    There should be some docs distributed along QScintilla... In case they are not there you could generate them with doxygen or consult the online docs.
    Current Qt projects : QCodeEdit, RotiDeCode

  5. #5

    Default Re: Code Completion in QScintilla

    THanks again my friend, is just that I think that QScintilla can help me 'cause all the features it has like: code folding and zoom, (I don't know if Qt components have it), and I was thinking that QScintilla's components are more flexible to higlithing code.
    When I said that "I get all I need from my compiler" is just that it do the lexer and sintax analysis, and give me an XML of what I need to put in the code-completion ListBox. That's way I want to use QScintilla, because of its features.

    Anyway if can help me about it, I mean if Qt components can bring me all the features I need.

  6. #6
    Join Date
    May 2006
    Posts
    788
    Thanks
    49
    Thanked 48 Times in 46 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Code Completion in QScintilla

    Yesterday i make a part on html edit on scintilla ... + line nummer ecc..
    && Completion word is only grep from the self page...

    if you like implement more word .. like sqllite db have a look on source ..
    http://www.qt-apps.org/content/show....?content=59422
    and subclass the db sql as QCompleter

    Qt Code:
    1. QViScintilla::QViScintilla( QWidget* parent )
    2. : QsciScintilla(parent)
    3. {
    4. const QString usersetfont = setter.value("DefaultFontsS").toString();
    5. QFont settfont;
    6. settfont.fromString(usersetfont);
    7. int fromsetting = settfont.pointSize();
    8. qDebug() << "### sci usersetfont " << usersetfont;
    9. qDebug() << "### sci fromsetting " << fromsetting;
    10. fontsize = 12;
    11. #if defined Q_WS_MAC
    12. fontsize = 22;
    13. #endif
    14. numerobase = 0;
    15. if (fromsetting > 2) {
    16. setFont(settfont);
    17. } else {
    18. QFont font;
    19. font.setFamily(QString::fromUtf8("Arial"));
    20. font.setPointSize(fontsize);
    21. setFont(font);
    22. }
    23.  
    24. /* QsciLexerHTML lexer overwrite font! */
    25. setPaper(QColor("#fbffcb"));
    26. setIndentationGuidesBackgroundColor(QColor("#e6e6de"));
    27. setAutoCompletionThreshold(2);
    28. setFolding(QsciScintilla::BoxedFoldStyle);;
    29. setMarginLineNumbers(1,true);
    30. setAutoCompletionFillupsEnabled(true);
    31. setAutoCompletionSource(QsciScintilla::AcsAll);
    32. setCaretWidth(10);
    33. setCaretLineBackgroundColor(QColor("#e6fff0"));
    34. setCaretLineVisible(true);
    35. ensureLineVisible(1);
    36. setUtf8(true);
    37. setWhitespaceVisibility(QsciScintilla::WsVisible);
    38. QsciLexerHTML *htmllex = new QsciLexerHTML(this);
    39. setLexer(htmllex);
    40. shortcut1 = new QShortcut(QKeySequence("Ctrl+S"),this);
    41. model = PAGER_LOADING_FUNCTIONS;
    42. connect(shortcut1, SIGNAL(activated()),this, SLOT(SaveCurrentDoc()));
    43. /////////connect(this, SIGNAL(textChanged()),this, SLOT(UpdateParent()));
    44. shortcut7 = new QShortcut(QKeySequence::ZoomOut,this); /* CTRL- */
    45. shortcut8 = new QShortcut(QKeySequence::ZoomIn,this); /* CTRL+ */
    46. connect(shortcut7, SIGNAL(activated()),this, SLOT(Decreasefont()));
    47. connect(shortcut8, SIGNAL(activated()),this, SLOT(Increasefont()));
    48. }
    49. void QViScintilla::Increasefont()
    50. {
    51. ////qDebug() << "### zoom + " << fontsize;
    52. zoomIn();
    53. }
    54.  
    55. void QViScintilla::Decreasefont()
    56. {
    57. ////qDebug() << "### zoom - " << fontsize;
    58. zoomOut();
    59. }
    To copy to clipboard, switch view to plain text mode 

Similar Threads

  1. Qt Cryptographic Architecture
    By vermarajeev in forum Qt Programming
    Replies: 6
    Last Post: 9th February 2007, 13:15
  2. Problem closing a QMainWindow in Qt4.2
    By ian in forum Qt Programming
    Replies: 11
    Last Post: 17th October 2006, 00:49
  3. problem with linking
    By mickey in forum Qt Programming
    Replies: 49
    Last Post: 12th August 2006, 21:41
  4. MSVC6 + qt3-win-commercial = no code completion
    By a550ee in forum Installation and Deployment
    Replies: 1
    Last Post: 20th March 2006, 12:17

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.