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?
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.