Painting in same widget above child objects of Itself
Sample code below.
- I have widget with child buttons.
- paintEvent(..) reimplemented. I'm drawing the line in paintEvent.
Issue - Line always below the buttons. I would like to see the line above the buttons. Is there a way to achieve this ?
b1 = new QPushButton("Monitor");
b2 = new QPushButton("Help");
hLyt = new QHBoxLayout; hLyt->addWidget(b1); hLyt->addWidget(b2); this->setLayout(hLyt);
void MyWidget::paintEvent(QPaintEvent *event)
IIRC, in that kind of situation, you would rather have an overlay widget on top of the other and paint that one.
I helped someone on the forums here recently with a tour my app type widget that did something similar. And I had to make it part of the widget I wanted to highlight. I couldn't just draw over other widgets. There may be a way but nothing popped into my mind while I was doing that.
Thank you @SGaist @ambershark. I have achieved my requirements through overlay. Just wanted to check possibility. I think it does not make sense to draw parent over children. So my question itself is not valid :)