[QScintilla] Setting Up Styles in QScintilla

Phil Thompson phil at riverbankcomputing.com
Mon Nov 5 19:19:16 GMT 2007


On Sunday 04 November 2007, Patrick Mabie wrote:
> To Phil
>          Thanks for your reply!
>
>
> Using Vista, msvc2005,C++,QScintilla-1.73-gpl-2.1
>
> I am trying to set Styles in QScintilla.
>
> textEdit->SendScintilla(textEdit->SCI_STYLESETFORE,m_pCpp->Comment,newColor
>);
>
> :-(
>
> This Fails , I am not sure why , but it does.

Why not use QsciLexer::setColor()?

> My Question is what is the proper way to do this , QScintilla is so well
> done, I must be  overlooking something.
>
> I am also trying to set up a api for the cpp lexer but it's failing to. :'(
> void Props::LoadStyles()
> {
>     m_pStyles << "Default" << "Comment" << "CommentLine" << "CommentDoc"
> << "Number" << "Keyword"
>    << "DoubleQuotedString" << "SingleQuotedString" << "UUID" <<
> "PreProcessor" << "Operator"  << "Identifier"
>    << "UnclosedString" << "VerbatimString" << "Regex"  <<
> "CommentLineDoc" << "KeywordSet2"
>    << "CommentDocKeyword" << "CommentDocKeywordError" << "GlobalClass";
> }
>
> void Props::LangCpp()
> {
>    CheckLexer();
>    m_pCpp = new QsciLexerCPP(textEdit);
>    SetLexer(m_pCpp);
>    m_pApi = new QsciAPIs(m_pCpp);
>
>    m_pApi = new QsciAPIs(m_pCpp);
>    foreach(QString style,m_pStyles)
>    {
>       m_pApi->add(tr("/")+style+tr("\\"));
>    }
>
>    m_pApi->prepare();
>    QString FileName = m_pApi->defaultPreparedName();
>     if(m_pApi->isPrepared(FileName))
>     {
>        m_pApi->savePrepared(FileName); <----------------- I never get to
> this point
>     }
> }
>
> Any help on either problem would greatly be appreciated.

isPrepared() only returns true if a file exists - which it probably doesn't 
because you haven't called savePrepared() yet.

Note that the only way to know when prepare() has finished it's work is to 
connect to the apiPreparationFinished() signal.

Phil


More information about the QScintilla mailing list