Important: Please read the Qt Code of Conduct -

QLineEdit and changing font for the "PlaceHolder" text

  • Is there a stylesheet tag I can use to change the font/font size of the placeholder text (and just that, leave the normal edit text as is) in QLineEdit?

  • Form what I've seen, there is only one font property, which applies to the regular text as well as to the place holder text.

    To work around you can attach signal textChanged() to a slot, check if the QString is empty or not and set the font property accordingly. I don't know if that would cause some flicker, though.

    Anyways, you might add an improvement issue to the "bug tracker":

  • One problem with Volker's proposal:

    If you do that in a signal, take care that changing the font changes the size hints and therefore might have impact on the layout.

  • well, Volker is a mad scientist ;-)

    Thank you both.

Log in to reply