#include #include #include #include class TestEdit : public QWidget { Q_OBJECT public: TestEdit() { input = new QPlainTextEdit(); mirror = new QPlainTextEdit(); output = new QPlainTextEdit(); mirror->setReadOnly(true); output->setReadOnly(true); QGridLayout* layout = new QGridLayout(); setLayout(layout); layout->addWidget(input, 0, 0, 1, 1); layout->addWidget(mirror, 0, 1, 1, 1); layout->addWidget(output, 1, 0, 1, 2); connect(input->document(), SIGNAL(contentsChange(int, int, int)), this, SLOT(TextChangedDoc(int, int, int))); resize(800,800); } private slots: void TextChangedDoc(int pos, int removed, int added); private: QPlainTextEdit* input; QPlainTextEdit* mirror; QPlainTextEdit* output; }; void TestEdit::TextChangedDoc(int pos, int removed, int added) { mirror->setPlainText(input->toPlainText()); output->appendPlainText(QString("contentsChange pos = %1, removed = %2, added = %3").arg(pos).arg(removed).arg(added)); } int main(int argc, char **argv) { QApplication app (argc, argv); TestEdit window; window.show(); return app.exec(); } #include "ime.moc"