def __init__(self): super().__init__() self.ui = Ui_MainWindow() self.ui.setupUi(self) self.scroll_area_content = get_child_widget( self, "scrollAreaWidgetContents") self.scroll_area_content.installEventFilter(self) # 550, 325, 550, 480 # 925, 325, 925, 480 geoms = [ (375, 350, 150, 130), (575, 350, 150, 130), (775, 350, 150, 130), (975, 350, 150, 130), ] for geom in geoms: text_input = QTextEdit(parent=self.scroll_area_content) text_input.setGeometry(*geom) text_input.show() geoms = [ (525, 480, 50, 50), (925, 480, 50, 50), ] for geom in geoms: btn = QPushButton(parent=self.scroll_area_content) btn.setGeometry(*geom) btn.setStyleSheet( "QPushButton {qproperty-icon: url(add.svg); background-color: rgb(255,255,255,0); qproperty-iconSize: 24px;}" ) btn.show()
def __init__(self): super().__init__() self.ui = Ui_MainWindow() self.ui.setupUi(self) self.scroll_area_content = get_child_widget( self, "scrollAreaWidgetContents") self.scroll_area_content.installEventFilter(self)
class Main(QMainWindow): resize_height = 0 resize_width = 0 def __init__(self): super().__init__() self.ui = Ui_MainWindow() self.ui.setupUi(self) self.scroll_area_content = get_child_widget( self, "scrollAreaWidgetContents") self.scroll_area_content.installEventFilter(self) def eventFilter(self, watched: PySide2.QtCore.QObject, event: PySide2.QtCore.QEvent): if watched is self.scroll_area_content and type(event) is QPaintEvent: normal_font = PySide2.QtGui.QFont('MS Shell Dlg 2', 14) underlined_font = PySide2.QtGui.QFont('MS Shell Dlg 2', 14) underlined_font.setUnderline(True) p = QPainter() p.begin(self.scroll_area_content) p.setPen(PySide2.QtGui.QColor(0, 0, 0)) p.setFont(normal_font) p.drawLine(250, 75, 500, 75) p.drawLine(375, 25, 375, 250) p.drawLine(200, 250, 550, 250) p.drawLine(200, 250, 200, 400) p.drawLine(550, 250, 550, 500) p.drawLine(175, 400, 225, 400) p.drawEllipse(545, 500, 10, 10) p.drawText(312, 50, "T") p.drawText(437, 50, "F") p.drawText(400, 170, "A") p.drawText(150, 350, "A") p.drawText(575, 350, "B") p.drawText(500, 450, "C") p.setFont(underlined_font) p.drawText(400, 120, "A|!A&(B|!C)") p.drawText(400, 220, "!A&(B|!C)") p.drawText(225, 300, "!A") p.drawText(575, 300, "B|!C") p.drawText(575, 400, "!C") p.end() self.scroll_area_content.setMinimumSize(700, 550) return False
def __init__(self): super().__init__() self.ui = Ui_MainWindow() self.ui.setupUi(self) self.scroll_area_content = get_child_widget( self, "scrollAreaWidgetContents") self.scroll_area_content.installEventFilter(self) normal_font = PySide2.QtGui.QFont('MS Shell Dlg 2', 14) btn = QPushButton(parent=self.scroll_area_content) btn.setText("B&&!C") btn.setGeometry(575, 280, 70, 30) btn.setFont(normal_font) btn.show()
class Main(QMainWindow): def __init__(self): super().__init__() self.ui = Ui_MainWindow() self.ui.setupUi(self) self.scroll_area_content = get_child_widget( self, "scrollAreaWidgetContents") self.scroll_area_content.installEventFilter(self) # 550, 325, 550, 480 # 925, 325, 925, 480 geoms = [ (375, 350, 150, 130), (575, 350, 150, 130), (775, 350, 150, 130), (975, 350, 150, 130), ] for geom in geoms: text_input = QTextEdit(parent=self.scroll_area_content) text_input.setGeometry(*geom) text_input.show() geoms = [ (525, 480, 50, 50), (925, 480, 50, 50), ] for geom in geoms: btn = QPushButton(parent=self.scroll_area_content) btn.setGeometry(*geom) btn.setStyleSheet( "QPushButton {qproperty-icon: url(add.svg); background-color: rgb(255,255,255,0); qproperty-iconSize: 24px;}" ) btn.show() def eventFilter(self, watched: PySide2.QtCore.QObject, event: PySide2.QtCore.QEvent): if watched is self.scroll_area_content and type(event) is QPaintEvent: normal_font = PySide2.QtGui.QFont('MS Shell Dlg 2', 14) underlined_font = PySide2.QtGui.QFont('MS Shell Dlg 2', 14) underlined_font.setUnderline(True) normal_pen = QPen(PySide2.QtGui.QColor(0, 0, 0)) dotted_pen = QPen(normal_pen) dotted_pen.setStyle(PySide2.QtCore.Qt.DashDotDotLine) p = QPainter() p.begin(self.scroll_area_content) p.setPen(normal_pen) p.setFont(normal_font) p.drawLine(250, 75, 500, 75) p.drawLine(375, 25, 375, 250) p.drawLine(200, 250, 550, 250) p.drawLine(200, 250, 200, 400) p.drawLine(550, 250, 550, 325) p.drawLine(175, 400, 225, 400) p.drawText(312, 50, "T") p.drawText(437, 50, "F") p.drawText(400, 170, "A") p.drawText(150, 350, "A") p.setFont(underlined_font) p.drawText(400, 120, "A|!A&(B&!C)") p.drawText(400, 220, "!A&(B&!C)") p.drawText(225, 300, "!A") p.drawText(575, 300, "B&!C") p.setPen(dotted_pen) p.drawLine(550, 325, 550, 480) p.drawLine(550, 325, 950, 325) p.drawLine(950, 325, 950, 480) p.end() self.scroll_area_content.setMinimumSize(1150, 550) return False