我想稍后在我的应用程序中访问QTextList格式,但它似乎总是在创建之后被删除
我已经知道了format()
函数
我这样创建QTextList:
cursor = self.textEdit.textCursor()
cursor.insertList(QTextListFormat.ListDisc)
稍后在应用程序中,我想返回格式,即ListDisc或任何其他格式;我确实:
list = self.textEdit.textCursor().currentList()
if(list):
print(list.format())
我在调用print的行中得到这个错误:
RuntimeError: Internal C++ object (PySide2.QtGui.QTextList) already deleted.
编辑:当在PySide2 5.12.1 windows 7上运行时,下面的MCVE给出了错误
import sys
from PySide2.QtWidgets import QApplication, QTextEdit, QMainWindow
from PySide2.QtGui import QTextListFormat
class Test(QMainWindow):
def __init__(self, fileName=None):
super(Test, self).__init__()
self.testList()
def testList(self):
self.textEdit = QTextEdit(self)
cursor = self.textEdit.textCursor()
cursor.createList(QTextListFormat.ListDisc)
list = self.textEdit.textCursor().currentList()
if(list):
print(list.format())
if __name__ == '__main__':
app = QApplication(sys.argv)
test = Test()
test.show()
目前没有回答
相关问题 更多 >
编程相关推荐