[Qt-interest] Problem with QtextCursor and Selecting Text

Soumen Banerjee soumen08 at gmail.com
Tue Dec 21 07:27:31 CET 2010


Hi,
Im making a TTS app using a library called espeak. Now, espeak
generates word events which I use to highlight the word being read out
now. The slot's code is like this-

void MainWindow::highlight_next()
{
    /*!
      Moves the cursor to the next word. Selects it.
      */
    if(!finding)
    {
        if(cursor.position() != 0)
            cursor.movePosition(QTextCursor::WordRight);
        cursor.movePosition(QTextCursor::NextCharacter);
        cursor.select(QTextCursor::WordUnderCursor);
        ui->textEdit->setTextCursor(cursor);
    }
}

Now, as I use the app, the selection begins to lag behind the text
actually being read. Ive tried making a counter to see if espeak is
generating the word events correctly. The final wordcount does match
the number of words in the text. I cant understand the reason for this
lag.
The full source for the app is here - https://github.com/soumen08/Narrator
Can someone help me with this?
Regards,
Soumen



More information about the Qt-interest-old mailing list