#include #include class TApplication : public QApplication { Q_OBJECT public: TApplication(int argc, char *argv[]) : QApplication(argc, argv) { m_editor.setPlainText("Hello"); connect(&m_editor, SIGNAL(textChanged()), this, SLOT(OnTextChanged())); } QPlainTextEdit m_editor; public slots: void OnTextChanged() { QTextCursor tc = m_editor.textCursor(); tc.movePosition(QTextCursor::Start, QTextCursor::MoveAnchor); } }; int main(int argc, char *argv[]) { TApplication a(argc, argv); a.m_editor.show(); return a.exec(); } #include "main.moc"