Results 1 to 2 of 2

Thread: Casting variables

  1. #1
    Join Date
    Apr 2010
    Posts
    13
    Thanks
    3
    Qt products
    Qt4
    Platforms
    Windows

    Default Casting variables

    Hello all,

    Need some advice on the best way to cast from sting to int etc... I come from vb6 world where if I had a textbox and someone typed the value in, I could cast it from a string to a in like this cint(text1.text). I am looking for the best way to do this in QT, not only for text boxes but any input or value.Also at times would need to cast a int... to a string.

    Currently I am instatiating a qstring, and calling setNum, there must be a better way.

    Thanks in advance.

  2. #2
    Join Date
    Jan 2006
    Location
    Belgium
    Posts
    1,938
    Thanked 268 Times in 268 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Wiki edits
    20

    Default Re: Casting variables

    QString::toInt() or toDouble() or ...
    QString::number()

    It's all in the documentation. Read it.

  3. The following user says thank you to tbscope for this useful post:

    axisdj (6th September 2010)

Similar Threads

  1. Problem with QGraphicsItem Casting
    By D Cell in forum Newbie
    Replies: 1
    Last Post: 9th April 2010, 19:11
  2. Problem with type casting
    By qtDave in forum Newbie
    Replies: 7
    Last Post: 9th November 2009, 20:57
  3. Problem with type casting?
    By Jyoti.verma in forum Qt Programming
    Replies: 2
    Last Post: 25th August 2009, 05:24
  4. Casting in a select sqlQuery
    By Kesy in forum Qt Programming
    Replies: 3
    Last Post: 25th November 2008, 15:12
  5. Casting QGraphicsItem
    By pherthyl in forum Qt Programming
    Replies: 1
    Last Post: 11th November 2007, 23:56

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
  •  
Qt is a trademark of The Qt Company.