Results 1 to 2 of 2

Thread: Transferring data input from a Widget to a cpp file

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

    Default Transferring data input from a Widget to a cpp file

    hi everyone,
    i m new to QT Programming, and i must create an interface in which a user inputs his question in a LineEdit and the related responses in some LineEdit Widgets.
    my probleme is that i dont know how to transfer those input datas that i get from LineEdits to a cpp file where then i can output those data in an external file.. pls help me

    n the next step is to read that external file and put back the question a LineEdit Widget and the related responses in Some CheckBox Widgets..

    pls help me, i dont know much QT data transfer..
    tnx

  2. #2
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: Transferring data input from a Widget to a cpp file

    Start with reading the detailed descriptions of QFile and QTextStream.

    Here are a couple of examples picked out of the documentation (follow the links above):
    Qt Code:
    1. // read
    2. QFile file("in.txt");
    3. if (!file.open(QIODevice::ReadOnly | QIODevice::Text))
    4. return;
    5.  
    6. QTextStream in(&file);
    7. while (!in.atEnd()) {
    8. QString line = in.readLine();
    9. process_line(line);
    10. }
    11.  
    12. // write
    13. QFile file("out.txt");
    14. if (!file.open(QIODevice::WriteOnly | QIODevice::Text))
    15. return;
    16.  
    17. QTextStream out(&file);
    18. out << "The magic number is: " << 49 << "\n";
    To copy to clipboard, switch view to plain text mode 
    J-P Nurmi

  3. The following user says thank you to jpn for this useful post:

    Ahmad (10th March 2007)

Similar Threads

  1. Qt 4.1.4 on VS2005 error- cannot open input file 'qtmain.lib'
    By Ashish in forum Installation and Deployment
    Replies: 10
    Last Post: 11th October 2006, 17:05
  2. speed of setdata - lots of items in treeview
    By Big Duck in forum Qt Programming
    Replies: 4
    Last Post: 6th July 2006, 13:53
  3. Replies: 3
    Last Post: 23rd June 2006, 18:46
  4. Replies: 4
    Last Post: 24th March 2006, 23:50
  5. Replies: 16
    Last Post: 7th March 2006, 16:57

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.