Results 1 to 6 of 6

Thread: How can I read from Text Edit

  1. #1
    Join Date
    Feb 2009
    Posts
    189
    Thanks
    2

    Question How can I read from Text Edit

    Dear Friends
    I have some values in Text Edit in the dialog box , the values are like below
    2 0.323 0.3232
    1st values is an ineteger and the rest two are doubles.

    How can I read these values independently from Text Edit. !!

    Any suggestion would be appreciated.

  2. #2
    Join Date
    Dec 2006
    Posts
    849
    Thanks
    6
    Thanked 163 Times in 151 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: How can I read from Text Edit

    you can't. grab the (complete) text as a QString and parse it.
    You can use QTextStream for reading the numbers.
    Qt Code:
    1. QString text = edit->toPlainText();
    2. QTextStream ts(&text, QIODevice::ReadOnly);
    3. double f1, f2, f3;
    4. ts >> f1 >> f2 >> f3;
    To copy to clipboard, switch view to plain text mode 

    HTH

  3. #3
    Join Date
    Feb 2009
    Posts
    189
    Thanks
    2

    Default Re: How can I read from Text Edit

    would this reading be sequential reading ??

  4. #4
    Join Date
    Dec 2006
    Posts
    849
    Thanks
    6
    Thanked 163 Times in 151 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: How can I read from Text Edit

    please rephrase that (or just try it out....)

  5. #5
    Join Date
    Feb 2009
    Posts
    189
    Thanks
    2

    Default Re: How can I read from Text Edit

    Thanks Friends let me I am trying it...

  6. #6
    Join Date
    Oct 2009
    Posts
    4
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Windows

    Default Re: How can I read from Text Edit

    Hi, i have created a project(Gui project) and in the main.cpp file i have some sql queries that gets data from a remote sever liekt this;
    if(!query.exec("SELECT..........")){
    qDebug()<<"FAIL";
    }
    while(query.next()){
    QString name = query.value(0).toString();
    qDebug() << name;
    }
    it works well and i have the results printed out like "abdnsh"
    Now in my .ui i have Text Edit. How can i append the sql reults to the Text Edit in my .ui?
    I'm a beginner, please i will appreciate

Similar Threads

  1. Unhandled exception in qatomic
    By NewGuy in forum Qt Programming
    Replies: 14
    Last Post: 23rd July 2013, 09:49
  2. Character encoding in text edit and llne edit
    By greenvirag in forum Qt Programming
    Replies: 3
    Last Post: 20th January 2009, 08:45
  3. Replies: 1
    Last Post: 15th January 2009, 10:34
  4. how to read from text edit in QT4
    By iamjayanth in forum Qt Programming
    Replies: 3
    Last Post: 17th October 2008, 12:51
  5. Replies: 8
    Last Post: 15th May 2007, 09:21

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.