[SOLVED] modificationChanged() will not be emitted after QTextEdit::setAlignment() called
Hi, there! I wonder if you have found this problem. After I called QTextEdit::setAlignment(Qt::AlignJustify), the textEdit->document()‘s modificationChanged(bool) will not be emitted. Here is the key code:
If I remove ui->textEdit->setAlignment(Qt::AlignJustify);, everything is OK. But if this line is not removed, the window title will not be changed. I’ve no idea if this is my fault or something else.
Thank you for your suggestions!
That’s a nasty one…
If this thread or the one at QtCentre [qtcentre.org]()-signal-will-not-emit-after-QTextEdit-setAlignment()-called Comes up with a solution, please notify the other forum as well.
This one is interesting enough to have a look at, but I lack the time at the moment.
I have found the problem. The signal modificationChanged(bool) will be emitted when QTextDocument::modified = true. If I called setAlignment() first, this function will set modified, so even I input some text, the signal will not be emitted again, the window title of course will not be changed. If you have to call setAlignment() first, just call QTextDocument::setModified(false); after steAlignment(). This will set modified = false, then everything is OK.