Results 1 to 3 of 3

Thread: String Manipulation and string functions

  1. #1
    Join Date
    Aug 2016
    Posts
    2
    Qt products
    Qt5 Qt/Embedded PyQt3 PyQt4
    Platforms
    Unix/X11 Windows Android

    Default String Manipulation and string functions

    Hi Guyz,
    I am new to QT ,I am trying to work with file and manipulate the string from file,I don't know how I can do this,

    I have an txt file containing below data,

    Target1 :ABCDEF $
    Target1 :GHIJ %
    Target2 : KLMNO$
    Target2 : PQRS%
    Target3: TUV
    Target4: XYZ

    I want to take ABCDEF , GHIJ ,KLMNO , PQRS , TUV , XYZ data alone.

    In normal C/C++ ,we use array, string functions and compare .... .I hope in QT also,there is a possibility but I dont know how to take advantage of the pre-defined methods in QT .



    for reading file I wrote this,

    void MainWindow::readFile()
    {
    QFile file("/home/renupapa/Desktop/QT/Testfile.txt");

    if(!file.open(QFile::ReadOnly|QFile::Text))
    {
    QMessageBox::warning(this,"Title","Error File not opened !!!!! ");

    }
    QTextStream in(&file);
    QString text=in.readAll();
    ui->plainTextEdit->setPlainText(text);
    file.close();
    }

    1. Can any one help me how I can take the specific data from the file and manipulate it ?


    2. Also where I can find clear guide on these QT methods with examples ?


    Thanks in Advance,
    E.Karthick

  2. #2
    Join Date
    Dec 2009
    Location
    New Orleans, Louisiana
    Posts
    791
    Thanks
    13
    Thanked 153 Times in 150 Posts
    Qt products
    Qt5
    Platforms
    MacOS X

    Default Re: String Manipulation and string functions

    You should first read the docs for QString. It has all of the builtin methods you would expect.
    I write the best type of code possible, code that I want to write, not code that someone tells me to write!

  3. #3
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: String Manipulation and string functions

    Quote Originally Posted by Snaidy View Post
    In normal C/C++ ,we use array, string functions and compare .... .I hope in QT also,there is a possibility but I dont know how to take advantage of the pre-defined methods in QT .
    I am not sure what you mean, Qt is a C++ library, whatever C++ code you have will also work when used with code using Qt.

    Quote Originally Posted by Snaidy View Post
    for reading file I wrote this,
    Since you have a line oriented file, I would be reading lines and then parsing each line, see jefftee's post and maybe also QRegularExpression.

    Cheers,
    _

Similar Threads

  1. Replies: 3
    Last Post: 8th June 2011, 06:36
  2. Replies: 4
    Last Post: 19th October 2010, 02:23
  3. String manipulation methods?
    By PaladinKnight in forum Newbie
    Replies: 5
    Last Post: 16th March 2010, 23:44
  4. std:string how to change into system:string?
    By yunpeng880 in forum Qt Programming
    Replies: 1
    Last Post: 14th April 2009, 08:51
  5. Int to String - manipulating string
    By mickey in forum General Programming
    Replies: 6
    Last Post: 5th November 2007, 20:11

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.