×

Discussion Board

Results 1 to 6 of 6
  1. #1
    Registered User
    Join Date
    Dec 2011
    Posts
    30

    QML how to set textfield as numeric

    hi
    please let me know how can i set textfied that it take only numbers
    as i want to make a phone no text field.thanks

  2. #2
    Super Contributor
    Join Date
    Mar 2009
    Posts
    1,024

    Re: QML how to set textfield as numeric

    You can use inputMethodHints property for that.

    TextInput {
    inputMethodHints: Qt.ImhDigitsOnly
    }

  3. #3
    Registered User
    Join Date
    Dec 2011
    Posts
    30

    Re: QML how to set textfield as numeric

    sir its no t working.plz tel me how can i restrict text feild to take only numeric no as my textfield is

    TextField {
    id: cellNoField
    x:3
    width: 345
    placeholderText: "Cell No"
    }

  4. #4
    Super Contributor
    Join Date
    Jun 2006
    Location
    India
    Posts
    3,037

    Re: QML how to set textfield as numeric

    check validator property also and u can define ur reg exp.
    Use [URL="http://qt.nokia.com/products/qt-quick/"]Qt-Quick[/URL] to make your application UI more attractive.

    [URL="http://store.ovi.com/content/271896"]http://store.ovi.com/content/271896[/URL] | [URL="http://store.ovi.com/content/276199"]http://store.ovi.com/content/276199[/URL] |[URL="http://store.ovi.com/content/276202"] http://store.ovi.com/content/276202[/URL] | [URL="http://store.ovi.com/content/280827"]http://store.ovi.com/content/280827[/URL]

  5. #5
    Super Contributor
    Join Date
    Mar 2009
    Posts
    1,024

    Re: QML how to set textfield as numeric

    Hi,
    inputMethodHints works fine. I tested it myself!
    there is a big difference between the validator and inputMethodHint.
    InputMethodHint changes the VKB layout, validator doesn't.
    if inputMethodHints property is set to Qt.ImhDigitsOnly, the VKB shows only numbers and +,-,. chars.

    Here is the code you can run on your device.

    import QtQuick 1.1
    import com.nokia.meego 1.0

    Page {
    tools: commonTools

    TextArea {
    anchors.fill: parent
    inputMethodHints: Qt.ImhDigitsOnly
    }
    }

  6. #6
    Super Contributor
    Join Date
    Jun 2006
    Location
    India
    Posts
    3,037

    Re: QML how to set textfield as numeric

    Quote Originally Posted by gnuton View Post
    Hi,
    inputMethodHints works fine. I tested it myself!
    there is a big difference between the validator and inputMethodHint.
    InputMethodHint changes the VKB layout, validator doesn't.
    if inputMethodHints property is set to Qt.ImhDigitsOnly, the VKB shows only numbers and +,-,. chars.

    Here is the code you can run on your device.

    import QtQuick 1.1
    import com.nokia.meego 1.0

    Page {
    tools: commonTools

    TextArea {
    anchors.fill: parent
    inputMethodHints: Qt.ImhDigitsOnly
    }
    }
    Yes, it is working for me also
    Use [URL="http://qt.nokia.com/products/qt-quick/"]Qt-Quick[/URL] to make your application UI more attractive.

    [URL="http://store.ovi.com/content/271896"]http://store.ovi.com/content/271896[/URL] | [URL="http://store.ovi.com/content/276199"]http://store.ovi.com/content/276199[/URL] |[URL="http://store.ovi.com/content/276202"] http://store.ovi.com/content/276202[/URL] | [URL="http://store.ovi.com/content/280827"]http://store.ovi.com/content/280827[/URL]

Similar Threads

  1. WRTKit TextField and alpha numeric VKB
    By mikah in forum Symbian
    Replies: 0
    Last Post: 2009-08-22, 23:18
  2. CommandListener on TextField.NUMERIC || TextField.PASSWORD
    By lekkie in forum Mobile Java General
    Replies: 3
    Last Post: 2007-07-09, 13:42
  3. Unfamiliar with Textfield.NUMERIC
    By jaceline in forum Personal Profile
    Replies: 1
    Last Post: 2006-05-18, 07:54
  4. TextField only allows numeric characters...
    By davidrenstrom in forum Mobile Java General
    Replies: 1
    Last Post: 2006-01-16, 15:47
  5. Numeric TextField max size 10digits?
    By epalite in forum Mobile Java General
    Replies: 5
    Last Post: 2005-11-10, 03:32

Posting Permissions

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