Results 1 to 5 of 5

Thread: Android, character counter for TextEdit

  1. #1
    Join Date
    May 2016
    Posts
    5
    Thanks
    1
    Qt products
    Qt5
    Platforms
    Android

    Default Android, character counter for TextEdit

    I'm trying to write a character counter for a TextEdit field.
    I have tryed numerous ways that work fine on the desktop, but on Android it fails when the space key is pressed and then only works when space key is pressed.
    What am I missing?

  2. #2
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Android, character counter for TextEdit

    I am not sure I understand.
    The length of the text does not increase if spaces are added on Android?

    Cheers,
    _

  3. #3
    Join Date
    May 2016
    Posts
    5
    Thanks
    1
    Qt products
    Qt5
    Platforms
    Android

    Default Re: Android, character counter for TextEdit

    No, here is some code that shows the problem:
    Qt Code:
    1. import QtQuick 2.0
    2. import QtQuick.Controls 1.3
    3. Item {
    4. Rectangle {
    5. id: textin
    6. anchors.top: parent.top
    7. anchors.topMargin: parent.height / 10
    8. width: parent.width * 0.8
    9. height: parent.height / 3
    10. anchors.horizontalCenter: parent.horizontalCenter
    11. border.color: "#000000"
    12. TextEdit {
    13. id: ptext
    14. anchors.fill: parent
    15. clip: true
    16. textMargin : 10
    17. wrapMode : Text.WordWrap
    18. text: "test"
    19. onTextChanged: {
    20. textcount.text = ptext.text.length
    21. console.log(text, ptext.text.length)
    22. }
    23. }
    24. Text {
    25. id: textcount
    26. anchors.bottom: textin.bottom
    27. anchors.right: textin.right
    28. width: parent.width * 0.2
    29. height: parent.height * 0.2
    30. }
    31. }
    32. }
    To copy to clipboard, switch view to plain text mode 

    qrc:/debug.qml:19 (onTextChanged): qml: test 4
    qrc:/debug.qml:19 (onTextChanged): qml: testa 5
    qrc:/debug.qml:19 (onTextChanged): qml: testab 6
    qrc:/debug.qml:19 (onTextChanged): qml: testabc 7
    qrc:/debug.qml:19 (onTextChanged): qml: testabc 8
    qrc:/debug.qml:19 (onTextChanged): qml: testabc 8
    qrc:/debug.qml:19 (onTextChanged): qml: testabc 8
    qrc:/debug.qml:19 (onTextChanged): qml: testabc 8
    qrc:/debug.qml:19 (onTextChanged): qml: testabc 8
    qrc:/debug.qml:19 (onTextChanged): qml: testabc test 12
    qrc:/debug.qml:19 (onTextChanged): qml: testabc test 13

  4. #4
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Android, character counter for TextEdit

    So after the first space the text doesn't actually change until the next space?

    I wonder why that triggers onTextChanged at all.

    Maybe the input method or virtual keyboard on Android holds modifications back, e.g. for auto completion, etc.?

    Cheers,
    _

  5. #5
    Join Date
    May 2016
    Posts
    5
    Thanks
    1
    Qt products
    Qt5
    Platforms
    Android

    Default Re: Android, character counter for TextEdit

    Yes thats the problem.
    I don't use auto-completion and the characters show in the TextEdit field.
    Any idea how to write a text lenght counter in QML that works on Android?

    Cheers,

Similar Threads

  1. Qt for Android: Character Encoding problems.
    By HeReSY in forum Qt Programming
    Replies: 2
    Last Post: 18th March 2012, 21:48
  2. Hi Help me! Rev Counter developed
    By toro.86 in forum Jobs
    Replies: 2
    Last Post: 12th October 2010, 21:19
  3. Character by Character (Unicode?) File Reading
    By mclark in forum Qt Programming
    Replies: 4
    Last Post: 22nd April 2009, 15:28
  4. How to read QStringList character by character
    By iamjayanth in forum Qt Programming
    Replies: 4
    Last Post: 3rd April 2009, 11:25
  5. Counter widget
    By eu.x in forum Newbie
    Replies: 7
    Last Post: 27th February 2007, 20:30

Tags for this Thread

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.