Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. convert textfield text in to double or int
Forum Updated to NodeBB v4.3 + New Features

convert textfield text in to double or int

Scheduled Pinned Locked Moved Unsolved Mobile and Embedded
6 Posts 3 Posters 2.1k Views 2 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • E Offline
    E Offline
    eswar
    wrote on last edited by p3c0
    #1

    I need to do some mathematical operation based on textfield.

    For ex:

    textfield:{
    id:tf1
     text:""
    ontextchanged{
    
    tf2.text=(tf1.text*50)/25
    }
    }
    textfield:{
    id:tf2
     text:""
    
    }
    

    Note: We enter real value (60.00) in tf1 and also we get real value(80.00) in tf2

    If i use the same calculation, i get output as zero.

    In that any text changed in textfield1 will automatically refeclt to the textfield2 and autocalculated value will be displayed in textfield2.

    1 Reply Last reply
    0
    • p3c0P Offline
      p3c0P Offline
      p3c0
      Moderators
      wrote on last edited by
      #2

      @eswar I think you should first convert it to float using parseFloat then perform calculations on it. You can find many example of JS related to it.

      157

      1 Reply Last reply
      0
      • E Offline
        E Offline
        eswar
        wrote on last edited by
        #3

        If i use phraseFloat , l get ouput like this
        qml: NaN
        qml: NaN

        1 Reply Last reply
        0
        • p3c0P Offline
          p3c0P Offline
          p3c0
          Moderators
          wrote on last edited by
          #4

          How did you use it ?

          157

          1 Reply Last reply
          0
          • V Offline
            V Offline
            Vicky Sharma
            wrote on last edited by p3c0
            #5

            @eswar
            Its working as per your need.

            I didn't find any time zero as per you are saying...

            TextField{
                id:tf1
                text:""
                width: 50
                onTextChanged: {
                    tf2.text=(tf1.text*50)/25
                    console.log(tf2.text);
                }
                }
                TextField{
                id:tf2
                text:""
                x:tf1.width + 50
                }
            
            1 Reply Last reply
            0
            • E Offline
              E Offline
              eswar
              wrote on last edited by eswar
              #6

              In that above method , based on the textfield1 the data in the textfield 2 is changed. In that textfield 2 , i set validator. The value lies in between 0 to 1000 will be apper in tf2. I entered higher value, the tf2 value will appear any values . The tf2 validator will not validate tf2 data. In tf2 the value only 0 to 1000 will be appear , if i enter any value in tf1. How can i achieve that?

              1 Reply Last reply
              0

              • Login

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • Users
              • Groups
              • Search
              • Get Qt Extensions
              • Unsolved