Results 1 to 6 of 6

Thread: QPlainTextEdit and input filtering

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,373
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Thanks
    3
    Thanked 5,019 Times in 4,795 Posts
    Wiki edits
    10

    Default Re: QPlainTextEdit and input filtering

    Quote Originally Posted by paul.schwann View Post
    I still can e.g. press AltGr-0 and get a "}" -> AltGr doesn't seem to be catched by modifiers()
    It should be.

    Do I really have to check all those keycodes and let them though? This seems odd to me.
    What would not seem odd to you?
    I think that playing with the key codes it too low level for my purpose...
    What is the purpose? What if I paste some text which is not composed from 0 and 1? Is it valid or not? If not, then you have to check the contents of the text edit each time it changes using the QTextDocument::contentsChange() signal and simply correct the changes you don't want. Note that you may wreck undo/redo with this though.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  2. #2
    Join Date
    Oct 2009
    Posts
    3
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QPlainTextEdit and input filtering

    Quote Originally Posted by wysota View Post
    It should be.


    What would not seem odd to you?

    What is the purpose? What if I paste some text which is not composed from 0 and 1? Is it valid or not? If not, then you have to check the contents of the text edit each time it changes using the QTextDocument::contentsChange() signal and simply correct the changes you don't want. Note that you may wreck undo/redo with this though.
    Hi Wysota,

    I am a bit lost here...

    It seems odd to me that I have to fiddle with tons of conditions although all I want is to avoid some text appear in the editor field. Why do I have to take care about all the control keys (which I don't even know)?

    Regarding the copy/paste problem: I expect to be able to hook into the copy/paste functions of the QPlainTextEdit and either filter all non-0/1 characters out of the text being pasted or at least reject the pase action if other than 0/1 is in the text.

    Let me ask another question: What function is called (and thus, I can override) if the QPlainTextEdit is supposed to insert/append additional text (or set new text)? Is there a single function responsible for this?
    This function might also be part of the QTextDocument instead of the QPlainTextEdit.
    -- I wasn't able to locate such a function (it may exist or not).

    Thanks & Regards,
    Paul

Similar Threads

  1. Maximum input length for QTextEdit or QPlainTextEdit ??
    By b_ginner in forum Qt Programming
    Replies: 2
    Last Post: 22nd August 2009, 20:57
  2. Replies: 1
    Last Post: 14th September 2008, 23:05

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
  •  
Qt is a trademark of The Qt Company.