Getting the text value of a lineEdit
Dear my friends... I am a very beginner in Qt. I am still learning hard this programming tool. I made it to do a sql connection inserting a record into my MySQL Database Server; I want to get a text value of a lineEdit which typed in by the user of my program (if I succeed to master Qt) and processed my by code as put it into a SQL Query or else. In Kylix I do it very simply, just do like this : " a=TEdit1.Text; ". if I do "lineEdit1." then I find only set<<...>> property and slot diplayed on the Qt Designer display as a hint. Please tell me how to get the value in the lineEdit widget. Thank you very much. __________________________________ Do you Yahoo!? Friends. Fun. Try the all-new Yahoo! Messenger. http://messenger.yahoo.com/
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On Friday 04 June 2004 8:13 am, Prabu Subroto wrote:
In Kylix I do it very simply, just do like this : " a=TEdit1.Text; ".
if I do "lineEdit1." then I find only set<<...>> property and slot diplayed on the Qt Designer display as a hint.
Please tell me how to get the value in the lineEdit widget.
lineEdit1.text Take a look at http://doc.trolltech.com/3.3/classes.html . It's a great reference for Qt's classes. - -- James Oakley Engineering - SolutionInc Ltd. joakley@solutioninc.com http://www.solutioninc.com -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.4 (GNU/Linux) iD8DBQFAwH4o4U2uQswGyDcRAvcFAKCxxcDSdWtS2SUHE9zzzShbkCBRBwCePTTx di/o9QIsvpaOmLyNMTh8Htc= =Gbpw -----END PGP SIGNATURE-----
If your line edit is named lineEdit1: lineEdit1->text() returns a QString; lineEdit1->text().ascii() returns a const char* (if you like using stl strings instead of QStrings). So, for example, you might say: //begin code QString textEntered; textEntered = lineEdit1->text(); //end code and then you have a QString textEntered with the text of lineEdit1 in it. Hope that helps. Preston Prabu Subroto wrote:
Dear my friends...
I am a very beginner in Qt. I am still learning hard this programming tool.
I made it to do a sql connection inserting a record into my MySQL Database Server;
I want to get a text value of a lineEdit which typed in by the user of my program (if I succeed to master Qt) and processed my by code as put it into a SQL Query or else. In Kylix I do it very simply, just do like this : " a=TEdit1.Text; ".
if I do "lineEdit1." then I find only set<<...>> property and slot diplayed on the Qt Designer display as a hint.
Please tell me how to get the value in the lineEdit widget.
Thank you very much.
__________________________________ Do you Yahoo!? Friends. Fun. Try the all-new Yahoo! Messenger. http://messenger.yahoo.com/
On Friday 04 June 2004 17:09, Preston wrote:
If your line edit is named lineEdit1:
lineEdit1->text() returns a QString;
lineEdit1->text().ascii() returns a const char* (if you like using stl strings instead of QStrings).
Watch out for locales and encodings! This will fail miserably for people living outside the U.S. (not using 7-bit ASCII code). QString::ascii() should only be used for debugging, not for anything the user ever sees. If you need to support only simple (8 bit) encodings, you can use QString::local8Bit() which will pick encoding based on the current locale settings. In general, it is a better idea to use Unicode (easy character access, but uses 16 bit per character) or UTF-8 (multi-byte characters, saves memory, but no trivial single character access). This is why Qt uses QString which uses Unicode internally. Plus, IMHO QString is much more powerful and much easier to use than STL strings. CU -- Stefan Hundhammer <sh@suse.de> Penguin by conviction. YaST2 Development SuSE Linux AG Nuernberg, Germany
Prabu Subroto wrote:
Dear my friends...
I am a very beginner in Qt. I am still learning hard this programming tool.
I made it to do a sql connection inserting a record into my MySQL Database Server;
I want to get a text value of a lineEdit which typed in by the user of my program (if I succeed to master Qt) and processed my by code as put it into a SQL Query or else. In Kylix I do it very simply, just do like this : " a=TEdit1.Text; ".
if I do "lineEdit1." then I find only set<<...>> property and slot diplayed on the Qt Designer display as a hint.
From Mac Qt 3.3.1 docs via QTAssistant. LineEdit1.text -> from this propertie you get a QString Object. LineEdit1.text() -> from this function you get a QString Object.
Please tell me how to get the value in the lineEdit widget.
Thank you very much.
Hope this helps, Stefan.
participants (5)
-
James Oakley
-
Prabu Subroto
-
Preston
-
S. Bulterman
-
Stefan Hundhammer