4

I have a mainwindow and more than two widget on mainwindow. I wanna draw lines on the whole mainwindow and when the line should be over the widgets not behind these widgets. I've tried overwrite paintevent function of mainwindow and draw a line directly but the line is behind widgets. What should I do?

Asuka
  • 301
  • 4
  • 16
  • You need to draw (continue) the line on the widgets too. – vahancho Mar 18 '16 at 13:36
  • @vahancho But paintevent function of my widgets have been used, how could I draw lines on the widgets? – Asuka Mar 18 '16 at 13:38
  • In the same way: override the paint event for **each** widget. You said, that you override paint event function of the main window only. – vahancho Mar 18 '16 at 14:08
  • Well, if I've overridden paint event function of some widgets, what could I do? – Asuka Mar 18 '16 at 14:10
  • I don't understand your need exactly, but it's so easy to make a GUI with line or polygon, path, circle, etc. with Qt Graphics View framework ! Have you an example image with your need ? – Mohamed Hamzaoui Mar 18 '16 at 22:22

1 Answers1

4

You need to have an overlay widget, i.e. a widget that covers the area of your main widget, but is above it. Then you implement paintEvent() in that overlay widget. See this question for more details.

Thomas McGuire
  • 5,308
  • 26
  • 45