Results 1 to 3 of 3

Thread: Converting to integer

  1. #1
    Join Date
    May 2007
    Posts
    315
    Thanks
    1
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Converting to integer

    Hi. I've got a question. I want to convert QString to int, to bo able to make some calculations. Is it correct:
    Qt Code:
    1. QString string = lineEdit->text();
    2. string.toInt();
    To copy to clipboard, switch view to plain text mode 
    In docs it isn't clearly explained. And if it's correctly, can to refer to this converted value?

  2. #2
    Join Date
    May 2007
    Posts
    5
    Thanked 2 Times in 2 Posts
    Qt products
    Qt3 Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Converting to integer

    That is the correct way to do it. However, you need to store the int value from the conversion function. To do this you would modify your code to be...

    Qt Code:
    1. QString string = lineEdit->text();
    2. int myInt = string.toInt();
    To copy to clipboard, switch view to plain text mode 

  3. #3
    Join Date
    May 2007
    Posts
    315
    Thanks
    1
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Converting to integer

    Thanks Regards

Similar Threads

  1. Problem in converting QString to QChar array?
    By KaKa in forum Qt Programming
    Replies: 2
    Last Post: 19th March 2007, 00:38
  2. Inserting Integer Values to table.
    By kenny_isles in forum Newbie
    Replies: 2
    Last Post: 22nd February 2007, 07:17
  3. Problem converting .ui files from Qt3 to 4
    By Amanda in forum Qt Programming
    Replies: 6
    Last Post: 28th October 2006, 04:34
  4. converting string to unsigned integer
    By mgurbuz in forum Qt Programming
    Replies: 4
    Last Post: 12th May 2006, 09:46
  5. Converting my UI to Qt4
    By Honestmath in forum Qt Programming
    Replies: 1
    Last Post: 14th April 2006, 23:58

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.