Results 1 to 4 of 4

Thread: problem with reading input data in qt

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Feb 2006
    Location
    Romania
    Posts
    2,744
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Thanks
    8
    Thanked 541 Times in 521 Posts

    Default Re: problem with reading input data in qt

    Hello,

    If you have everything text oriented, do this:

    Instead of :
    Qt Code:
    1. int nbQuestion;
    2. in >> nbQuestion;
    To copy to clipboard, switch view to plain text mode 

    do this:
    Qt Code:
    1. int nbQuestion = 0;
    2. QString strNumOfQuestions;
    3. in >> strNumOfQuestions;
    4. nbQuestion = strNumOfQuestions.toInt();
    To copy to clipboard, switch view to plain text mode 


    Do this for every integer you read from the stream.

    Regards

  2. #2
    Join Date
    Feb 2006
    Location
    Romania
    Posts
    2,744
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Thanks
    8
    Thanked 541 Times in 521 Posts

    Default Re: problem with reading input data in qt

    Anyway, the problem was because int QTextStream:perator>>() was not going to the next line in case of "\n" or "\r\n" was encountered.

  3. #3
    Join Date
    Mar 2007
    Posts
    16
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Thanks
    9

    Default Re: problem with reading input data in qt

    Hey tnx a lot for the the post,
    in fact , i havent tried yet ur solution, but for meanwhile i putted an String varialbe after reading each integer which reads the \n and pass to next line.. and this has solved my problem

    QString nothing;
    nothing.readLine();


    but i know i should pass to a better method.

Similar Threads

  1. Transferring data input from a Widget to a cpp file
    By Ahmad in forum Qt Programming
    Replies: 1
    Last Post: 10th March 2007, 09:59
  2. reading DVD data and mpeg2 streams
    By guestgulkan in forum General Programming
    Replies: 1
    Last Post: 18th February 2007, 22:24
  3. reading and writing data from a QTableWidget
    By zorro68 in forum Qt Programming
    Replies: 4
    Last Post: 29th January 2007, 20:51
  4. speed of setdata - lots of items in treeview
    By Big Duck in forum Qt Programming
    Replies: 4
    Last Post: 6th July 2006, 12:53
  5. scanf not reading input correctly
    By jamadagni in forum General Programming
    Replies: 1
    Last Post: 8th January 2006, 15:54

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.