Search code examples
c++qwidgetqt5.6

QWidget background transparent


I have a widget in the main window, the widget has the following styles:

    background-color:#ffeeeeee;width:100%;height:100%;

It is set-up to widget layout and controls auto size to fill the geometry of the widget, but the background of the widget is always transparent. What can I do to make it opaque?

This is using Qt5.6 running on RedHat Linux 7.2

NOTE: The syntax #ffeeeeee is specific to Qt, where the first node is the alpha, then red, green and blue octets.


Solution

  • With the background-color present and set to any of the following:

        background-color:white;width:100%;height:100%;
    

    or

        background-color:#ffffff;width:100%;height:100%;
    

    or my original:

        background-color:#ffeeeeee;width:100%;height:100%;
    

    The property, autoFillBackground is set to false and the background of the widget is transparent at run-time.

    However removing any background-color style and leaving the style as just:

        width:100%;height:100%
    

    The property, autoFillBackground is set to true and the widget is opaque.

    As far as I can see there is no error in the styles, I believe this may be an error in Qt.