How to make a custom QWidget partially transparent?



  • Hi ,I have a custom Qwidget.If its (X-coordinate + Width ) value is greater than a particular value;say Z,then I want the QWidget to be visible till the coordinate Z and invisible or transparent after Z.Does Qt provide any attribute specifically ? Could someone give me a hint of how it can be approached.


  • Moderators

    @Adit
    Is this widget inside a window/layout or is it a top-level widget?
    The shape needs to be rectangular or an arbitrary shape?

    see QWidget::setMask()



  • Thanks for the reply raven.The structure is

    Window
    |-> GroupBox->QLabel->CustomQWidget

    So , I have simulated like as if my CustomQWidget is inside the QLabel Box.When I give some input which is greater than my
    CustomQWidget's X() + CustomQWidget's Width() , I want to make the rest of the CustomQWidget transparent and irresponsive.


  • Lifetime Qt Champion

    Hi
    Does the custom CustomQWidget do its own drawing with QPainter ?