Results 1 to 3 of 3

Thread: Browsing search text upwards and downwards

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Wiki edits
    17

    Default Re: Browsing search text upwards and downwards

    Probably a combination of SCi_SETCURRENTPOS(), SCI_SETANCHOR() and SCI_SCROLLCARET().

    I would probably have used the Scintilla searching functions to locate the text.
    http://www.scintilla.org/ScintillaDoc.html#Searching

  2. #2
    Join Date
    Oct 2015
    Posts
    2
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Browsing search text upwards and downwards

    Thanks As suggested by you,
    I modified code block as follows.
    Qt Code:
    1. void searchText( const QString& sText, bool bDown)
    2. {
    3. QString data = m_pTextEdit->text();
    4. m_pTextEdit->SendScintilla(QsciScintilla::SCI_INDICATORCLEARRANGE, 0, data.length());
    5.  
    6. if (sText.isEmpty())
    7. {
    8. return;
    9. }
    10.  
    11. int index = data.indexOf(sText, 0, Qt::CaseInsensitive);
    12. int length = sText.length();
    13.  
    14. if (bDown == true)
    15. {
    16. m_pTextEdit->SendScintilla(QsciScintilla::SCI_SETANCHOR, index);
    17. m_pTextEdit->SendScintilla(QsciScintilla::SCI_SETCURRENTPOS, index);
    18. m_pTextEdit->SendScintilla(QsciScintilla::SCI_SCROLLCARET, 0);
    19. edit_SearchText->setFocus();
    20. }
    21.  
    22. while (index >= 0) {
    23. m_pTextEdit->SendScintilla(QsciScintilla::SCI_INDICSETSTYLE,0 ,QsciScintilla::INDIC_ROUNDBOX);
    24. m_pTextEdit->SendScintilla(QsciScintilla::SCI_INDICSETFORE, 0x007f00);
    25.  
    26. m_pTextEdit->SendScintilla(QsciScintilla::SCI_INDICATORFILLRANGE, index, length);
    27. index = data.indexOf(sText, index + length, Qt::CaseInsensitive);
    28. }
    29. }
    To copy to clipboard, switch view to plain text mode 

    Still no luck of moving selection to next occurrence when search down key is pressed.

Similar Threads

  1. Highlight text given a search string
    By jrsanders in forum Qt Programming
    Replies: 0
    Last Post: 29th May 2015, 17:56
  2. How do I search for files which contain a specific text string?
    By rolandburt in forum General Programming
    Replies: 1
    Last Post: 20th August 2012, 21:32
  3. Thread Search in text file large
    By marcos.miranda in forum Newbie
    Replies: 11
    Last Post: 12th June 2012, 20:54
  4. Replies: 4
    Last Post: 25th May 2008, 20:01
  5. Text search utility
    By NewGuy in forum Newbie
    Replies: 7
    Last Post: 23rd July 2006, 11:59

Tags for this Thread

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
  •  
Qt is a trademark of The Qt Company.