Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. How can I make QLineEdit paint a different text than the one assigned?

How can I make QLineEdit paint a different text than the one assigned?

Scheduled Pinned Locked Moved Unsolved General and Desktop
2 Posts 2 Posters 737 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • scastielloS Offline
    scastielloS Offline
    scastiello
    wrote on last edited by
    #1

    Hello,

    I have a QLineEdit with a numerical validator ranging from -100 to 100. But I need the symbol "-" to be represented with the character "M".

    I have already tried the following:
       - Overwrite the text () method and do the replacement here. (It does not work)
       - Override the displayText () method and put the setEchoMode (). (It does not work)
       - Override the paintEvent () method. (Works, but does not look the same as any other QLineEdit)

    Is there anything else I can do to get this effect?

    Thanks all in advance.

    1 Reply Last reply
    0
    • m.sueM Offline
      m.sueM Offline
      m.sue
      wrote on last edited by m.sue
      #2

      Hi,
      in case of a QSpinBox I did something similar by overriding the QValidator::State validate(QString &input, int &pos) const function (changing numbers 1,2,... to characters A,B,...). So either you could use a QSpinBox instead of the QLineEdit or maybe it's possible to do the same thing using the fixup method of a QValidator that you add to the QLineEdit.
      -Michael.

      1 Reply Last reply
      2

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved