Results 1 to 2 of 2

Thread: qtextedit searchable?

  1. #1
    Join Date
    Oct 2010
    Posts
    58
    Thanks
    26
    Qt products
    Qt4
    Platforms
    Windows

    Default qtextedit searchable?

    Hi All,

    I was wondering if anyone could give me some pointers on how I can make a qtextedit searchable? I want the users of my program to be able to press ctrl+f, then a little window opens where they can type in a word or sentence then press enter to cycle through all the instances of the word in the qtextedit. I would also want the instances of the word to be highlighted. You know, just like in many web browsers and many other programs.

    Is there a function in Qt that can do this? Or if not, does anyone have some ideas on a good way to implement this?

    If there is no easy way, I am thinking I'll have to make some signals and slots, then get the text within the textedit, search that text for the word being searched, set all the instances to red, but how move the focus to each instance with ENTER pressed? Any and all random pointers would be appreciated.

    Thanks for your time!

  2. #2
    Join Date
    Jul 2009
    Location
    Enschede, Netherlands
    Posts
    462
    Thanked 69 Times in 67 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: qtextedit searchable?

    You can search through the QTextEdit's QTextDocument (QTextEdit::document()). The QTextDocument documentation shows how to search through the text.
    Horse sense is the thing that keeps horses from betting on people. --W.C. Fields

    Ask Smart Questions

  3. The following user says thank you to franz for this useful post:

    kja (21st June 2011)

Similar Threads

  1. QTextEdit Help !
    By chendy in forum Qt Programming
    Replies: 3
    Last Post: 1st April 2009, 03:18
  2. Replies: 1
    Last Post: 16th February 2007, 07:22
  3. QTextEdit Help Please
    By Raystorm in forum Newbie
    Replies: 8
    Last Post: 17th May 2006, 04:50
  4. QTextEdit help pls
    By munna in forum Newbie
    Replies: 2
    Last Post: 29th April 2006, 09:07
  5. 4.1 to 4.1.1, qtextedit
    By jey in forum Qt Programming
    Replies: 5
    Last Post: 9th March 2006, 12:48

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.