Qt World Summit: Register Today!

[Solved] How to prevent internal editor from invoking with QLineEdit

  • Hi,

    I have subclassed QLineEdit, because I need to have control on what is entered into it (basically it's a field for changing PIN code to application) so I have buttons and user is supposed to click on them to enter old PIN/new PIN (this is page for changing it). Now, because I subclassed QLineEdit it is sending clicked() signal, so i know which one is edited, but how to disable internal editor from showing up?
    I'm using Qt 4.7.3 on Symbian^3 (N8)

    best regards

  • Could be more clear on what you are asking. I have difficulties to understand the situation.

    You say you have buttons (QPushButton) ... but in this case you should have a widget containing this button (a QLineEdit is not a container!).
    Now you are saying 'how to disable internal editor', a QTextEdit without editor is a QLabel, isn't?

  • So I have page (on my application) called "PIN change" - this is PIN to log into this application.
    On this page I have buttons arranged as a keyboard from phone (1,2,3,...0) and I have three fields (currently QLineEdit's) with labels: enter old pin, enter new pin, reenter new pin.
    Now user is supposed to enter old pin and new pin by clicking numbers on my keyboard. I connected signal clicked (from subclassed QLineEdit) to some function that enables my keyboard and when user clicks the numbers they appear on proper QLineEdit.
    PIN should have only numbers, four of them, thats why I made keyboard.
    So the problem is that when user clicks on QLineEdit (in order to emit signal clicked, which I intercept, to get notification which pin is entered now, old or new) the default text editor is called with characters, digits and symbols - and I don't need that.

    However maybe I simply shouldn't use QLineEdit at all, just some QLabel with proper background color and subclass it if it doesn't already have clicked() signal - thats probably simplest solution.


  • That's exactly the remark I will do: why not a QLabel. You're never editing why did you need such a complex one? But of course which could more could less, the QTextEdit has a read-only modus:


  • Right, setReadOnly works for me.

    Many thanks

Log in to reply