class MdiChild(QtGui.QTextEdit):
sequenceNumber = 1
def __init__(self):
super(MdiChild, self).__init__()
self.setAttribute(QtCore.Qt.WA_DeleteOnClose)
self.isUntitled = True
def newFile(self):
self.isUntitled = True
self.curFile = "document%d.txt" % MdiChild.sequenceNumber
MdiChild.sequenceNumber += 1
self.setWindowTitle(self.curFile + '[*]')
self.document().contentsChanged.connect(self.documentWasModified)
def documentWasModified(self):
self.setWindowModified(self.document().isModified())
this code display the document1.txt as title of sub window when new sub window is created and keep increamenting. The title of sub window change from document1.txt to document1.txt.* when i change text in QTextedit and if i remove [] around * it display document1.txt.* when a new window is opened. so i want to know what is the working of [] in this code for document title and how * is append to document title.
And please also tell the meaning of the following line:
self.setAttribute(QtCore.Qt.WA_DeleteOnClose)
As mentioned in the docs
If you use the windowModified mechanism, the window title must contain a "[]" placeholder, which indicates where the '' should appear. Normally, it should appear right after the file name (e.g., "document1.txt[*] - Text Editor"). If the windowModified property is false (the default), the placeholder is simply removed.
Now you second question about self.setAttribute(QtCore.Qt.WA_DeleteOnClose)
WA_DeleteOnClose
clears the memory of the closed document.