Results 1 to 4 of 4

Thread: Retrieving and converting values

  1. #1
    Join Date
    Feb 2009
    Posts
    8
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Windows

    Default Retrieving and converting values

    Say I've got a QLineEdit and I need to retrieve the text, then convert it to a float for processing. How would I do that? The ways I've been trying so far always end up throwing compilation errors.

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,364
    Thanks
    3
    Thanked 5,012 Times in 4,791 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Retrieving and converting values


  3. #3
    Join Date
    Feb 2009
    Posts
    8
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Windows

    Default Re: Retrieving and converting values

    So would that be something like:

    double d = myLineEditName->text()->toDouble();

    It's the syntax that I'm not getting.

  4. #4
    Join Date
    Dec 2007
    Posts
    40
    Thanks
    6
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11

    Default Re: Retrieving and converting values

    Quote Originally Posted by jcoop View Post
    So would that be something like:

    double d = myLineEditName->text()->toDouble();

    It's the syntax that I'm not getting.
    double d = myLineEdit->text().toDouble();
    try breaking the operation sequence into series of steps...syntax evolves itself!

    cheers!
    Let your work talk for you

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.