Results 1 to 4 of 4

Thread: How to replace a particular text in a file located at any place..?

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    May 2011
    Location
    Mumbai, India
    Posts
    22
    Thanks
    2
    Qt products
    Qt3 Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default How to replace a particular text in a file located at any place..?

    hey can any1 tel me how to replace the text in a file which is located at any place......?
    and can can i edit any .ini file....below is my code....

    Qt Code:
    1. QFile file("E:/qtpro/ABC/abc.ini");
    2. file.open(QIODevice::ReadWrite | QIODevice::Text);
    3. file.reset();
    4.  
    5. QTextStream fl(&file);
    6.  
    7. QString str;
    8.  
    9.  
    10. while (!file.atEnd())
    11.  
    12. {
    13.  
    14. str = fl.readLine();
    15.  
    16. if (str == ";extension=abc_123.dll")
    17. {
    18. fl<<"extension=abc_123.dll"<<str<<"\n";
    19. }
    20. //else
    21. //{
    22. //fl<<str<<"\n";
    23. //}
    24. str = file.readLine();
    25.  
    26. }
    To copy to clipboard, switch view to plain text mode 
    Last edited by Ketan Shah; 23rd May 2011 at 14:41.

Similar Threads

  1. Where is the Qbluetooth file located?
    By nachiket bora in forum Qt Programming
    Replies: 6
    Last Post: 11th April 2011, 09:20
  2. Replies: 3
    Last Post: 3rd May 2009, 08:58
  3. Replies: 3
    Last Post: 21st April 2009, 05:25
  4. QString - find and replace text
    By graciano in forum Newbie
    Replies: 3
    Last Post: 24th January 2009, 20:35
  5. Replace text
    By Hz in forum Qt Programming
    Replies: 2
    Last Post: 22nd March 2006, 08:16

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.