Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. [SOLVED] modificationChanged() will not be emitted after QTextEdit::setAlignment() called
Forum Updated to NodeBB v4.3 + New Features

[SOLVED] modificationChanged() will not be emitted after QTextEdit::setAlignment() called

Scheduled Pinned Locked Moved General and Desktop
4 Posts 3 Posters 4.6k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • O Offline
    O Offline
    orangestar
    wrote on last edited by
    #1

    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:

    @MainWindow::MainWindow(QWidget parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
    {
    ui->setupUi(this);
    setWindowTitle(tr("Text [
    ]"));
    ui->textEdit->setAlignment(Qt::AlignJustify);
    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!

    1 Reply Last reply
    0
    • F Offline
      F Offline
      Franzk
      wrote on last edited by
      #2

      That's a nasty one...

      If this thread or the one at "QtCentre":http://www.qtcentre.org/threads/36806-modificationChanged()-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.

      "Horse sense is the thing a horse has which keeps it from betting on people." -- W.C. Fields

      http://www.catb.org/~esr/faqs/smart-questions.html

      1 Reply Last reply
      0
      • W Offline
        W Offline
        Wolf P.
        wrote on last edited by
        #3

        [quote author="Franzk" date="1291961877"] If this thread or the one at "QtCentre":http://www.qtcentre.org/threads/36806-modificationChanged()-signal-will-not-emit-after-QTextEdit-setAlignment()-called Comes up with a solution, please notify the other forum as well.[/quote]

        Can anyone place an appropriate link to "this thread":http://developer.qt.nokia.com/forums/viewthread/2311/ there? I've no account yet. Thx!

        1 Reply Last reply
        0
        • O Offline
          O Offline
          orangestar
          wrote on last edited by
          #4

          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.

          1 Reply Last reply
          0

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved