Results 1 to 10 of 10

Thread: How to take user input in lineEdit and write that to file

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Dec 2012
    Posts
    3
    Qt products
    Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Exclamation How to take user input in lineEdit and write that to file

    Hello QT Experts
    I have searched and searched and searched, I know you hear that from everyone. Please just point me in the right direction and I will leave you alone

    I have form, it has a textEdit on it labeled textEdit, among other things such as a couple of spin boxes and a lineEdit as well. The user can enter text into the lineEdit box and change the values of the spinbox and click a push button, when clicked it displays the values into textEdit. At the same time it will create a file in c:\ and write "You did something" into the file.

    What I can't find is how to take the values of ANY of those form elements such as textEdit and write that value to the file. I know how to write to file I know how to write the value to the textEdit I just can't seem to find an example of how to one into the other.

    I have a header file called mywrite.h it has all my void write () in it that create the file and write the information to file. Within this file I have the following:
    Qt Code:
    1. void Write2(QString Filename2){
    2. QFile mfile2(Filename2);
    3. if (!mfile2.open(QIODevice::WriteOnly | QIODevice::Text))
    4. {
    5. qDebug() << "could not open file";
    6. return;
    7. }
    8.  
    9. QTextStream stream(&mfile2);
    10. stream >> ui->textEdit->text();
    11. }
    To copy to clipboard, switch view to plain text mode 
    Instead of the word stream I have tried "out" and that doesn't make any difference I get the following three errors:
    C:\QTDEVDAY\1262012\MyFirstApp\myqtapp.cpp:72: error: C2065: 'ui' : undeclared identifier
    C:\QTDEVDAY\1262012\MyFirstApp\myqtapp.cpp:72: error: C2227: left of '->textEdit' must point to class/struct/union/generic type
    type is ''unknown-type''
    C:\QTDEVDAY\1262012\MyFirstApp\myqtapp.cpp:72: error: C2227: left of '->text' must point to class/struct/union/generic type

    I am sure it is something simple, like needing a signal/slot of some sort or something, or just a simple syntax change, I just don't know what that would be and can't seem to find an example.

    If you can just simple past a link to an exact example of how to write the ui lineEdit or textEdit to a file that would be great, that is all I really want to do. This is a test example for me, I have a form with 20 lineEdits on it that I want to write to a file when button is pushed, that is really all I need to do.

    thank you for your help in advance!!

    Doc
    Last edited by wysota; 11th December 2012 at 10:05. Reason: missing [code] tags

Similar Threads

  1. hoe to write user input data into QTcpserver port
    By gauravg in forum Qt Programming
    Replies: 1
    Last Post: 27th April 2012, 05:47
  2. How to input Chinese characters in LineEdit or TextEdit ?
    By behlkush in forum Qt Programming
    Replies: 2
    Last Post: 23rd May 2011, 12:26
  3. User Input using QString
    By kumarpraveen in forum Newbie
    Replies: 4
    Last Post: 9th July 2010, 07:49
  4. LineEdit for Hexadecimal input
    By mastupristi in forum Qt Programming
    Replies: 2
    Last Post: 21st January 2010, 14:51
  5. read and write content of lineedit widget in Other Form
    By validator in forum Qt Programming
    Replies: 1
    Last Post: 25th April 2008, 15:07

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.