Home > other >  PyQt5 how to use QPainter draw lines on QScrollArea?
PyQt5 how to use QPainter draw lines on QScrollArea?

Time:10-13

A QWidget interface to add an interface with the scroll bar, how to use QPainter draw lines on the interface?
` ` `
The class test (QWidget) :
Def __init__ (self) :
Super () __init__ ()
.
.
Self. SetUI ()

Def setUI (self) :
Self. SetGeometry (250, 200, 1500, 750)
Self. SetWindowTitle (' data structure the visualization simulator ')

Self. TopFiller=QWidget ()
Self. TopFiller. SetMinimumSize (1200, 2000)
Self. Scroll=QScrollArea ()
Self. Scroll. SetWidget (self topFiller)

The self. The Vbox=QVBoxLayout ()
The self. The Vbox. AddWidget (self. Scroll)
Self. SetLayout (self. Vbox)
` ` `

QPainter () what object should fill out? Why add QPushButton on the self can be displayed on the scroll bar interface, and draw lines will be a scroll bar interface block?
` ` `
Def paintEvent (self, e) :
Qp=QPainter (self)
Pen=QPen ()
Pen. SetWidth (1)
Qp. SetPen (pen)
Qp. DrawLine (15, 80, 1080, 120)
` ` `
  • Related