Results 1 to 3 of 3

Thread: print text in the lineEdit control from string

  1. #1
    Join Date
    Jan 2010
    Posts
    28
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default print text in the lineEdit control from string

    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?
    Last edited by rk0747; 6th February 2010 at 03:12.

  2. #2
    Join Date
    Jul 2009
    Location
    Enschede, Netherlands
    Posts
    462
    Thanked 69 Times in 67 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: print text in the lineEdit control from string

    [plcno->text = text]
    is this correct way to print the text from string? or ui->plcno->text()=text
    Uhm, how about
    Qt Code:
    1. ui->plcno->setText(text);
    To copy to clipboard, switch view to plain text mode 

    [if(n= "PLCName")]
    is this correct way to check the condition?
    No. The equality operator is ==. This is an assignment. Your check should be
    Qt Code:
    1. if (n == "PLCName") {
    2. }
    To copy to clipboard, switch view to plain text mode 

    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).
    Last edited by franz; 6th February 2010 at 08:46.
    Horse sense is the thing that keeps horses from betting on people. --W.C. Fields

    Ask Smart Questions

  3. #3
    Join Date
    Jan 2008
    Location
    Poland
    Posts
    687
    Thanks
    4
    Thanked 140 Times in 132 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: print text in the lineEdit control from string

    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.
    I would like to be a "Guru"

    Useful hints (try them before asking):
    1. Use Qt Assistant
    2. Search the forum

    If you haven't found solution yet then create new topic with smart question.

Similar Threads

  1. how to print string??
    By pratik in forum Qt Programming
    Replies: 7
    Last Post: 25th December 2010, 16:38
  2. Get text from dynamic lineedit
    By wirasto in forum Qt Programming
    Replies: 1
    Last Post: 13th January 2010, 18:56
  3. How to enabled button, when i changed lineedit`s text ?
    By newermind in forum Qt Programming
    Replies: 8
    Last Post: 13th August 2009, 08:57
  4. Enabling buttons when lineEdit has text
    By k12yp70n in forum Newbie
    Replies: 4
    Last Post: 29th May 2009, 07:18
  5. Lineedit text change signal
    By zgulser in forum Qt Tools
    Replies: 2
    Last Post: 19th January 2009, 13:38

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.