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. Searching and deleting strings
Qt 6.11 is out! See what's new in the release blog

Searching and deleting strings

Scheduled Pinned Locked Moved General and Desktop
4 Posts 2 Posters 1.0k Views 1 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.
  • Q Offline
    Q Offline
    Qangel
    wrote on last edited by
    #1

    Hello, I've recently joined this group and used Qt for 3 months.
    I have been coding an address book. I store data in a file and use QTreeview to display them.
    My current problem is how to search a string in a file, find it and then delete it.
    Please I need help.
    Sorry for mistake!!! English is not my mother tongue.
    Have a nice day.

    1 Reply Last reply
    0
    • S Offline
      S Offline
      Sirius27
      wrote on last edited by
      #2

      hi!
      you might be looking for this:

      @QByteArray textData;
      QFile file(myFile);
      file.open(QFile::ReadWrite|QFile::Text);
      textData= myFile.readAll();
      QString strText(textData);

      @

      and then use a :
      QString & QString::remove(const QString & str, Qt::CaseSensitivity cs = Qt::CaseSensitive)

      //check out QString docs

      1 Reply Last reply
      0
      • Q Offline
        Q Offline
        Qangel
        wrote on last edited by
        #3

        Thank you a lot, I am going to try it...

        1 Reply Last reply
        0
        • S Offline
          S Offline
          Sirius27
          wrote on last edited by
          #4

          :) sure

          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