Qt 5.5.1

My objective is to display the line and column of the cursor in a QTextEdit object. It works properly using keys like enter and backspace to navigate, but the arrow keys seem to move the caret without changing the cursor position (the display for line and column number will stay the same despite the caret moving elsewhere for this reason). How can I make it so the arrow keys change the cursor position so I can update my label?

Here is my code that updates the display when the cursor position changes:
Qt Code:
  1. QTextCursor cursor = ui->textEdit->textCursor();
  2.  
  3. // ...
  4.  
  5. void MainWindow::on_textEdit_cursorPositionChanged()
  6. {
  7. ui->statusBar->showMessage("Line " + QString::number(cursor.blockNumber() + 1)
  8. + ", Col " + QString::number(cursor.positionInBlock() + 1));
  9. }
To copy to clipboard, switch view to plain text mode