Semi-transparent QTextEdit

  • Hi all,

    I've been trying to get a QTextEdit control to draw its background semi-transparently, but to no avail. I've lost count on the number of different methods I've tried:

    • setting the palette, both to the QTextEdit control itself, and to the viewport() (i.e. a Palette with colors for both QPalette::Base and QPalette::Background set to RGBA colors)
    • calling control->setStyleSheet with background set to "none"
    • this method:
      @ control->setAttribute( Qt::WA_TranslucentBackground, true );


    • and this:

    • and finally this:
      @QGraphicsOpacityEffect* effect = new QGraphicsOpacityEffect( control );
      effect->setOpacity( 0.75 );
      control->setGraphicsEffect( effect );

    • and of course a number of combinations of some or all of these methods

    but nothing works.

    A thing to note is that I'm NOT adding this control to a layout, since it is absolutely positioned on top of other windows.

    I'm currently on page 3 in the Google search, will continue to go deeper.

    Any ideas?


  • you have to set your window flag for you QTextEdit to Qt::FramelessWindowHint so it can work with the first option

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.