Important: Please read the Qt Code of Conduct -

Generated QLineEdit has transparent background colour; how to set to local default background.

  • I have a subclass of a QStyledItemDelegate. When the user double-clicks a particular index in a view, the createEditor function is called and in some simple cases, all I do is create a QLineEdit and pass back a pointer to it.

    However, on some target operating-system/window-manager combos (Ubuntu running Gnome, in this case), the text that was visible in that location before is still visible, through the QLineEdit. Like a background, painted on the QLineEdit. Those characters are not part of the QLineEdit text; the cursor is at the start, and as I type the new characters appear over the top of the other, visible characters. It's as if the QLineEdit begins life with the background colour set to "transparent". I can set my own background colour

    lineEdit->setStyleSheet("QLineEdit{background: red;}");

    but that's ugly; I'd really like the background colour to match whatever the current default background colour is, so that it remains pretty across all OS/window-manager combos. So is there a "local background" colour or some such?

Log in to reply