1

Im a newbie to Qt. 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.

RAM
  • 2,257
  • 2
  • 19
  • 41
adi
  • 984
  • 15
  • 33

1 Answers1

0

One approach would be an explicit overpaint with a transparent brush, using the Source composition mode. For this, the top-level widget needs to be set to allow translucency, and a child overlay widget covering the entire top-level widget would then overpaint transparency where needed.

Another approach would be to use a frameless widget with a custom, emulated frame, and hold all child widgets in a subwidget, with the subwidget a child in the top-level widget, and with no layout manager on the top-level widget. The top-level would effectively clip all of the children and act like a window onto them. A special resize handler for the top-level would be needed to manage the subwidget's size and position, as well as the top-level's size. The minimum vertical size constraint would need to be propagated from the subwidget to the top-level widget.

Both approaches should be relatively easy to implement (<100 lines).

Kuba hasn't forgotten Monica
  • 95,931
  • 16
  • 151
  • 313
  • Thanks for the reply Kuba Ober.Which approach is better for a resolution independent UI ?Could you suggest me some tutorials/examples for the 1st approach. – adi Jun 14 '18 at 08:47
  • Either one doesn't care about resolution. I have some answers about overlays, and also an answer with composition modes (with a text rendering example). Combining them should give you most information you need for the first approach. – Kuba hasn't forgotten Monica Jun 14 '18 at 10:12