Important: Please read the Qt Code of Conduct -

Cursor width in QLineEdit when using inputMask

  • I am using inputMask in QLineEdit. When I execute this, the pixelWidth of cursor in QLineEdit is increased by approx 8 pixels while cursor is in normal size in other widgets. I want cursor in normal size. How can this be done?

    I have also designed a class inheriting QProxyStyle class to modify pixelWidth of cursor. When I increse cursor width using this, it is working fine but doesn't work while decreasing

  • Your question is unclear to me.

    Can you show some of your code which causes to the erroneous result?

    And if you can show a screenshot of what is happening it is much better.

  • Lifetime Qt Champion


    AFAIK, the different pixel width is normal. It lets the users know that there's an input mask. Otherwise they will have a hard time understand why not every character they input shows on the line edit.

  • So isnt there any solution if i want normal pixelWidth.

  • Thanks SGaist.
    Now i think cursor pixelWidth is not an issue to my GUI.
    But I am facing another problem in this. I want this lineEdit with inputMask to work same as we have input field for IP Address, so that cursor can jump after/ before any non-space character on pressing any arrow key. For this i have used QLineEdit::setCursorPosition() method. It is working fine but cursor is not visible at random times. Can anyone tell me about this behaviour of cursor?

  • Lifetime Qt Champion

    I'm not sure I am getting you right. Can you provide a an example ?

Log in to reply