Results 1 to 6 of 6

Thread: How to split a string line

  1. #1
    Join Date
    Jul 2009
    Location
    Bangalore
    Posts
    68
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    Unix/X11

    Default How to split a string line

    Hi All,

    I am reading a line from a text file as
    56, 545.682, 897.000, -12.369
    and the i am storing into an array datumstr[datumno_val] then how to split this string line and display in numberlineEdit=56, XlineEdit= 545.682, YlineEdit=897.000, and ZlineEdit=-12.369
    Thanks & Regards
    Sandeep G.R.

  2. #2
    Join Date
    Aug 2008
    Location
    Ukraine, Krivoy Rog
    Posts
    1,963
    Thanked 370 Times in 336 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: How to split a string line

    take a look at QString::split.
    Qt Assistant -- rocks!
    please, use tags [CODE] & [/CODE].

  3. #3
    Join Date
    Jul 2009
    Location
    Bangalore
    Posts
    68
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    Unix/X11

    Default Re: How to split a string line

    I am using qt-3.3 but QString::split() is in qt-4 please help me to resolve this issue
    Thanks & Regards
    Sandeep G.R.

  4. #4
    Join Date
    Jul 2009
    Posts
    139
    Thanks
    13
    Thanked 59 Times in 52 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: How to split a string line

    You can do it manually. If you are having trouble, have a look at a split implementation (or just copy and paste it).

  5. #5
    Join Date
    Sep 2008
    Location
    Bangalore
    Posts
    659
    Thanks
    116
    Thanked 42 Times in 41 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: How to split a string line

    then u convert it in to normal chat* and
    do our own c method of strtok()

    code to convert QString to const char*
    Qt Code:
    1. const char *str;
    2. QString path;
    3. ba = path.toLatin1();
    4. str = ba.data();
    5. printf("the string path will be:%s\n", str);
    To copy to clipboard, switch view to plain text mode 
    "Behind every great fortune lies a crime" - Balzac

  6. #6
    Join Date
    Dec 2006
    Posts
    849
    Thanks
    6
    Thanked 163 Times in 151 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: How to split a string line

    Qt3: see QStringList::split(); the function was moved in Qt4

Similar Threads

  1. Why is my application's CPU usage always > 50%
    By richardander in forum Qt Programming
    Replies: 10
    Last Post: 14th October 2010, 22:22
  2. QTcpSocket exception.
    By Fastman in forum Qt Programming
    Replies: 9
    Last Post: 29th January 2008, 13:51
  3. Qwizard crashed when created in a slot
    By joshlareau in forum Qt Programming
    Replies: 9
    Last Post: 15th January 2008, 09:16
  4. KDE/QWT doubt on debian sarge
    By hildebrand in forum KDE Forum
    Replies: 13
    Last Post: 25th April 2007, 06:13
  5. QTableView paints too much
    By Jimmy2775 in forum Qt Programming
    Replies: 2
    Last Post: 26th July 2006, 18:42

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.