LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 01-05-2009, 12:50 PM   #1
navderm
Member
 
Registered: Dec 2008
Location: Chandigarh, India
Distribution: Red Hat 9
Posts: 67

Rep: Reputation: 15
gettting the text details in QT


Hie..
I am using QT to make a small program. How should I get the text from the QLineEdit named lineEdit1 and put it into another QTextLabel ??
the command

i tried

textLabel1.setCaption(/*what do i write here*/);

does it differ when you use designer (hence you write this code in a slot of a button in a *.ui.h) and when you use cpp (hence you write this code in a slot of a button in a .cpp) file ???

Please help
 
Old 01-05-2009, 01:32 PM   #2
matthewg42
Senior Member
 
Registered: Oct 2003
Location: UK
Distribution: Kubuntu 12.10 (using awesome wm though)
Posts: 3,530

Rep: Reputation: 65
The QLineEdit class has a "text" property, so you cold try this:
Code:
textLabel1.setCaption(lineEdit1.text());
Furthermore, you can connect the signal from lineEdit1, "textChanged(QString)" to the textLanel1 slot, "setText(QString)", and then whenever the line edit is modified, the label will be updated automatically.
 
Old 01-05-2009, 08:00 PM   #3
navderm
Member
 
Registered: Dec 2008
Location: Chandigarh, India
Distribution: Red Hat 9
Posts: 67

Original Poster
Rep: Reputation: 15
Hi.
I wrote exactly this in the slot for a button which is evoked when the signal clicked() is emitted from the button. But is shows some compiling error. I guess it is because I am using designer and I wrote that code in .ui.h file which somehow is not supporting the same command. So what is the solution? Should I stop working with designer coz I am getting a lot more issues with improving the functionality of many of the buttons.
Or is there a way to get out of this trauma of having to write long code just to get something like a textbox tested of some small property.???

Please help.
 
Old 01-05-2009, 08:02 PM   #4
navderm
Member
 
Registered: Dec 2008
Location: Chandigarh, India
Distribution: Red Hat 9
Posts: 67

Original Poster
Rep: Reputation: 15
Also...if after getting the text can i convert it to a double value by function (atof()) ??
 
Old 01-05-2009, 08:49 PM   #5
navderm
Member
 
Registered: Dec 2008
Location: Chandigarh, India
Distribution: Red Hat 9
Posts: 67

Original Poster
Rep: Reputation: 15
Okie here is what i do..

void (this is a slot_name))
{
Qstring a;
a = lineEdit->text();
static float b =0;
b+= atof(a);
std::cout <<b<<endl;
label->setCaption(a);
}

here everything works but the last line. the labels caption is not changing?????
and this was a hand coded program.
If I make a program by designer, how do I get this code running?? Where do I write these lines?????
 
Old 01-07-2009, 01:59 PM   #6
Mara
Moderator
 
Registered: Feb 2002
Location: Grenoble
Distribution: Debian
Posts: 9,696

Rep: Reputation: 232Reputation: 232Reputation: 232
At least in Qt3, you should add
Code:
label->show();
at the end. Probably the same with version 4...
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
read a line from text file and extracting the details needed pdklinux79 Linux - Newbie 6 06-06-2008 10:41 PM
Gettting ENOTCONN when sending data, but the socket was opened. trevelluk Programming 3 05-12-2005 10:43 AM
Doom3 and Cevedega keep gettting erro=21 ipoql Linux - Newbie 2 09-22-2004 04:28 PM
On installing gettting error messages? PJamz Linux - Newbie 1 09-06-2004 12:51 AM
Gettting slackware online??? Volcom General 2 06-09-2003 03:56 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 10:54 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration