×

Discussion Board

Results 1 to 2 of 2
  1. #1
    Regular Contributor
    Join Date
    Apr 2008
    Posts
    445

    Convert qreal to int in Qml

    Hi,

    I do some calculation directly in Qml code which results in a float (qreal) value. Now I want to convert this value to a int which I want to show as text.
    Code:
    var somefloat = 1.1222;
    textlabel.text = (int)somefloat;
    How can I convert the float to int directly in Qml? Truncation and rounding are both okay as solutions.

    Regards,

  2. #2
    Regular Contributor
    Join Date
    Apr 2008
    Posts
    445

    Re: Convert qreal to int in Qml

    I already found the solution:
    Code:
    Math.round();

Similar Threads

  1. Converting qreal to qstring
    By Nujabrn in forum Qt
    Replies: 6
    Last Post: 2010-12-15, 12:21
  2. Rounding float/qreal numbers
    By danhicksbyron in forum Qt
    Replies: 3
    Last Post: 2010-03-13, 03:45
  3. How can i convert?
    By martinmachi in forum General Development Questions
    Replies: 1
    Last Post: 2010-02-24, 12:22
  4. Is there some MMS to convert between MM1 and MM7?
    By neilgao in forum General Messaging
    Replies: 0
    Last Post: 2005-08-18, 11:49
  5. convert to 3gp
    By OsellaS in forum General Development Questions
    Replies: 0
    Last Post: 2004-08-09, 10:28

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×