Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Search up/down using QsciScintilla
Forum Updated to NodeBB v4.3 + New Features

Search up/down using QsciScintilla

Scheduled Pinned Locked Moved General and Desktop
qsciscintillaqlineeditsearchwindows
3 Posts 3 Posters 1.7k Views 2 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Y Offline
    Y Offline
    Yatshan
    wrote on last edited by Yatshan
    #1

    Hi
    I have written following code to find occurrences of a given text in whole text document. Following code will highlight all such occurrences. But when I click search down / search up buttons it doesn't move cursor to next occurrence. Can anyone please help to achieve this task.
    bool bDown parameter is intended to be used to indicate whether to move cursor up/down. But Still I am clueless of how to use this parameter.

    QsciScintilla *m_pTextEdit;

    void searchText( const QString& sText, bool bDown)
    {
    QString data = m_pTextEdit->text();
    m_pTextEdit->SendScintilla(QsciScintilla::SCI_INDICATORCLEARRANGE, 0, data.length());

    if (sText.isEmpty())
    {
    	return;
    }
    
    int index = data.indexOf(sText, 0,  Qt::CaseInsensitive);
    
    while (index >= 0) {
    int length = sText.length();
    m_pTextEdit->SendScintilla(QsciScintilla::SCI_INDICSETSTYLE,0 ,QsciScintilla::INDIC_ROUNDBOX);
    m_pTextEdit->SendScintilla(QsciScintilla::SCI_INDICSETFORE, 0x007f00);
    
    m_pTextEdit->SendScintilla(QsciScintilla::SCI_INDICATORFILLRANGE, index, length);
    index = data.indexOf(sText, index + length, Qt::CaseInsensitive);	 
    }
    

    }

    JKSHJ 1 Reply Last reply
    0
    • Y Yatshan

      Hi
      I have written following code to find occurrences of a given text in whole text document. Following code will highlight all such occurrences. But when I click search down / search up buttons it doesn't move cursor to next occurrence. Can anyone please help to achieve this task.
      bool bDown parameter is intended to be used to indicate whether to move cursor up/down. But Still I am clueless of how to use this parameter.

      QsciScintilla *m_pTextEdit;

      void searchText( const QString& sText, bool bDown)
      {
      QString data = m_pTextEdit->text();
      m_pTextEdit->SendScintilla(QsciScintilla::SCI_INDICATORCLEARRANGE, 0, data.length());

      if (sText.isEmpty())
      {
      	return;
      }
      
      int index = data.indexOf(sText, 0,  Qt::CaseInsensitive);
      
      while (index >= 0) {
      int length = sText.length();
      m_pTextEdit->SendScintilla(QsciScintilla::SCI_INDICSETSTYLE,0 ,QsciScintilla::INDIC_ROUNDBOX);
      m_pTextEdit->SendScintilla(QsciScintilla::SCI_INDICSETFORE, 0x007f00);
      
      m_pTextEdit->SendScintilla(QsciScintilla::SCI_INDICATORFILLRANGE, index, length);
      index = data.indexOf(sText, index + length, Qt::CaseInsensitive);	 
      }
      

      }

      JKSHJ Offline
      JKSHJ Offline
      JKSH
      Moderators
      wrote on last edited by
      #2

      Hi @Yatshan, and welcome to the Qt Dev Net!

      Sorry I don't have any experience with Scintilla, so I don't know how to solve your problem. Have you tried asking the person who created QsciScintilla?

      Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

      1 Reply Last reply
      0
      • P Offline
        P Offline
        Peggyw
        wrote on last edited by Peggyw
        #3

        @Yatshan said in Search up/down using QsciScintilla:

        m_pTextEdit->SendScintilla(QsciScintilla::SCI_INDICATORCLEARRANGE, 0, data.length());

        This really helped me with clearing all the highlights!
        I tried QsciScintilla::SCI_MARKERDELETEALL for many times but no luck.
        Thanks!

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved