Results 1 to 12 of 12

Thread: Reading a text file

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,017 Times in 4,793 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Reading a text file

    You are aware 'file' variable from line #3 and the one from line #18 are different variables, right?

    One warning from me -- when asked for code if you ever again post pseudo-code then I will either ignore your post or give you a pseudo-answer comparable to your pseudo-code.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  2. #2
    Join Date
    Oct 2014
    Posts
    71
    Thanks
    13
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Reading a text file

    I think till now you understand what exactly I am asking for.
    I have recognize the Problem and my problem is in below code
    Qt Code:
    1. void ui_logging::Button_Clicked()
    2. {
    3.  
    4. QTextStream in(file); //My Problem is here on every click I am creating the object again and again
    5.  
    6. for( i = 0;i<10;i++)
    7. {
    8.  
    9. in>>str1;
    10. qDebug()<<str1;
    11.  
    12. }
    13. int n = in.pos();
    14.  
    15.  
    16. }
    To copy to clipboard, switch view to plain text mode 
    Do you have any solution for the above.

  3. #3
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,017 Times in 4,793 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Reading a text file

    The file is probably a class member variable. Make the stream a class member variable as well.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


Similar Threads

  1. Qwtplot: reading data from text file
    By GG2013 in forum Newbie
    Replies: 0
    Last Post: 31st May 2013, 07:03
  2. Advice: Reading large text file.
    By enricong in forum Qt Programming
    Replies: 7
    Last Post: 16th July 2011, 12:11
  3. Problem: Reading and editing text file data
    By dipeshtech in forum Newbie
    Replies: 2
    Last Post: 2nd May 2011, 23:47
  4. Reading from text file
    By jerkymotion in forum Qt Programming
    Replies: 5
    Last Post: 17th March 2011, 11:26
  5. Replies: 1
    Last Post: 3rd September 2008, 14: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.