×

Discussion Board

Results 1 to 5 of 5
  1. #1
    Registered User
    Join Date
    May 2009
    Location
    Guatemala
    Posts
    186

    Question How to limit the max length of QML TextEdit element ?

    Hello.

    I don't seem to find a way to limit the number of characters that are allowed to be entered in a QML TextEdit element.

    Something like the TextInput's maximumLength property.

    I need to allow the user to enter multiline text. If there is another type of element that I should use instead of TexEdit, please let me know.

    Any comments/answers really appreciated.

    Thanks.
    -CarlosDL

  2. #2
    Registered User
    Join Date
    May 2009
    Location
    Guatemala
    Posts
    186

    Re: How to limit the max length of QML TextEdit element ?

    Nokia support said that I would need to implement this property in a custom QTextEdit in c++, and expose it to QML.

    An interesting exercise that I will leave for some other day.

    As a workaround I'm currently using a 0-opacity TextInput (with a maximumLength set) and a Text element. When the Text's mouse area is clicked I set the focus to the non-visible TextInput and make it show its software input panel. The entered text is then shown in the multiline Text (whose text property is bound to the TextInput's text one).

    Not very elegant, but fast to implement.

    I'm still open to suggestions.
    -CarlosDL

  3. #3
    Registered User
    Join Date
    Apr 2009
    Posts
    23

    Re: How to limit the max length of QML TextEdit element ?

    I haven't dulged into this, but can't you just count the number of characters in the string on every TextChanged signal and whenever the number of characters hits your limit you set some parameter (probably editable or something) to false?

  4. #4
    Registered User
    Join Date
    May 2009
    Location
    Guatemala
    Posts
    186

    Re: How to limit the max length of QML TextEdit element ?

    Quote Originally Posted by Seikeau View Post
    I haven't dulged into this, but can't you just count the number of characters in the string on every TextChanged signal and whenever the number of characters hits your limit you set some parameter (probably editable or something) to false?
    Some variant of that concept should definitely be used to implement it, but it's not trivial. It should be taken into account that the user might want to delete characters (so the text should still be editable), or move the cursor position from the end of the string and start adding more text (so you cannot just take left(0,maxLength) as the valid input), etc.

    Also, not sure how efficient that would be using the signal-slot mechanism.

    I appreciate the suggestion.

    Thanks,
    -CarlosDL

  5. #5
    Registered User
    Join Date
    Apr 2009
    Posts
    23

    Re: How to limit the max length of QML TextEdit element ?

    The weird thing is that TextInput does have a variable to limit the amount of characters, I suppose it's a matter of time before that's implemented in TextEdit.

    Otherwise you might be able to look up how it's implemented in TextInput and port that, You have to have some knowledge of Qt / C++ tho.

Similar Threads

  1. Max text length limit for a pop-up.
    By ravinder007 in forum Symbian
    Replies: 1
    Last Post: 2007-09-18, 12:26
  2. How I get the max limit of a progress Bar
    By jyotideep in forum Symbian User Interface
    Replies: 2
    Last Post: 2007-01-02, 08:35
  3. how to set the max length of contact's field
    By xiaowato in forum Symbian
    Replies: 2
    Last Post: 2006-08-22, 11:11
  4. How to change the max length of TPtr
    By rensijie in forum Symbian
    Replies: 2
    Last Post: 2006-08-13, 04:31
  5. the max length of socket's string
    By yinjialiang in forum Symbian Networking & Messaging (Closed)
    Replies: 3
    Last Post: 2003-08-11, 16:24

Posting Permissions

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