[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:
- ui(new Ui::MainWindow)
- {
- ui->setupUi(this);
- setWindowTitle(tr("Text [*]"));
- connect(ui->textEdit->document(), SIGNAL(modificationChanged(bool)),
- this, SLOT(setWindowModified(bool)));
- }
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!
3 replies
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.
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.
Can anyone place an appropriate link to this thread [developer.qt.nokia.com] there? I’ve no account yet. Thx!
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.
You must log in to post a reply. Not a member yet? Register here!


