PDA

View Full Version : print text in the lineEdit control from string



rk0747
6th February 2010, 03:50
hi
this is my code:


QSTRING text;
QDOM DOCUMENT DOC("myfile.xml")
qdomelement ELEMENT = DOC.DocumentElement();
for(QDomNode n = element.firstChild();!n.isNull(); n = n.nextSibling())
{
if(n= "PLCNO")
{
QDomText t = n.toText();
if (!t.isNull())
text = t.data();
plcno->text = text
}

if(n= "PLCName")
{
QDomText t = n.toText();
if (!t.isNull())
text = t.data();
plcname->text = text //(Converting string to text)
}

}

here i want to print the text(string value) in the Lineeditcontrol(plcno and plcname),

[plcno->text = text]
is this correct way to print the text from string? or ui->plcno->text()=text

if(n= "PLCName")
is this correct way to check the condition?

franz
6th February 2010, 09:41
[plcno->text = text]
is this correct way to print the text from string? or ui->plcno->text()=text


Uhm, how about


ui->plcno->setText(text);




[if(n= "PLCName")]
is this correct way to check the condition?

No. The equality operator is ==. This is an assignment. Your check should be


if (n == "PLCName") {
}


Next time, use code tags around your code. Also you should read a bit about C and C++ coding. You are going to get yourself stuck if you don't (you have already).

faldzip
6th February 2010, 09:48
Your both ways are incorrect. Please learn some C++ basics first before asking next question, ok? If don't know simple comparison operator then how do you want to write some application? It looks like you don't know how to drive a car but want to win in Arctic Rally in some WRC car. First you should learn for what there is a gear shift, right? And get know which pedal is a gas, which is a brake and which is a clutch, right?
So run google, type "c++ tutorial" or equivalent in your language and start from the simple Hello World and do all the exercises without copy and paste. Then read and understand Qt Examples about widgets, XMLs and other stuff and then start writing your app.