Results 1 to 2 of 2

Thread: search for a specific string of text and then return the line number?

  1. #1
    Join Date
    Jul 2010
    Posts
    1
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default search for a specific string of text and then return the line number?

    I'm looking for the best way in QT to search for a specific string of text and then return the line number.
    For example I have a txt file that has the following in it:

    1 Detroit Tigers
    2 Chicago White Sox
    3 Minnesota Twins

    I want to search for the word Twins and return the string 3.

    Any ideas??

    Thanks

  2. #2
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: search for a specific string of text and then return the line number?

    read the file line by line in and check every line for your pattern. This is probably the fastest way.

Similar Threads

  1. How to read line number in a text file
    By grsandeep85 in forum Qt Programming
    Replies: 7
    Last Post: 31st July 2009, 10:09
  2. How to search a string in xml file with Qt Dom classes
    By doganay44 in forum Qt Programming
    Replies: 2
    Last Post: 5th October 2006, 21:16
  3. Converting number to string.
    By safknw in forum Newbie
    Replies: 2
    Last Post: 18th September 2006, 13:12
  4. how to move cursor to specific line in Text
    By showhand in forum Qt Programming
    Replies: 1
    Last Post: 24th August 2006, 10:55
  5. count line number in text
    By Alina in forum Qt Programming
    Replies: 2
    Last Post: 18th August 2006, 09:29

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.