pyqt:从qlineEdit中删除布局

2024-09-30 06:27:22 发布

您现在位置:Python中文网/ 问答频道 /正文

我有一个QlineEditText,它是我给Qlayout的我想更新它,但它说:

QLayout: Attempting to add QLayout "" to QLineEdit "lineEdit_2", which already has a layout

MTL.Convert(self.lineEdit_2,'$' + str(self.lineEdit.text()) + '$')

class MathTextLabel(QtWidgets.QWidget):
    #def __init__(self, mathText, parent=None, **kwargs):
    def Convert(txt, mathText):
        super(QtWidgets.QWidget, txt)

        l=QVBoxLayout(txt)

        l.setContentsMargins(0,0,0,0)

        r,g,b,a=txt.palette().base().color().getRgbF()

        txt._figure=Figure()

        txt._canvas=FigureCanvas(txt._figure)

        l.addWidget(txt._canvas)

        txt._figure.clear()

        text=txt._figure.suptitle(
            mathText,
            x=0.0,
            y=1.0,
            horizontalalignment='left',
            verticalalignment='top',
            size=QtGui.QFont().pointSize()*2
        )

这是第一次将Latex转换为布局中的方程式,而不是第二个QlineEditText 但当我在第一个文本框中更改latex Eq后再次按下按钮时,它会显示:

QLayout: Attempting to add QLayout "" to QLineEdit "lineEdit_2", which already has a layout


Tags: toselftxtaddwhichfigurehaslayout

热门问题