Details
-
Bug
-
Resolution: Unresolved
-
P2: Important
-
4.4.3, 5.4.0 Beta
-
None
Description
When pasting some words (say "add") at the 0 position of an existing line in a document, signal contentsChange() shows incorrect value for second and third parameter (charsRemoved, charsAdded).
To reproduce this Run the following code:
Type: add rest
select "add" without space and cut
now past at 0 position
you will see out put: Position= 0 Chars Removed 6 Chars Added 9
#include <QtGui> class MainWindow : public QMainWindow { Q_OBJECT public: MainWindow(QWidget *parent = 0) { setWindowTitle("Tesxt contentChange Signal"); QTextEdit * textEdit = new QTextEdit; setCentralWidget(textEdit); connect(textEdit->document(), SIGNAL(contentsChange(int,int,int)), this, SLOT(myContentsChangeFunction(int,int,int))); } private: public slots: void myContentsChangeFunction(int a,int b,int c) { qDebug()<<"Position="<<a<<"Chars Removed"<<b<<"Chars Added"<<c; } }; #include "main.moc" int main(int argc, char *argv[]) { QApplication app(argc, argv); MainWindow mainWindow; mainWindow.show(); return app.exec(); }
Another side-effect of this problem is that when you paste text at 0 position then undo(), the cursor is returned to position (1,0) and not (0,0) as it should be. This can be reproduced with TextEdit demo of Qt4.4.3. To reproduce follow these steps.
- Run the TextEdit demo in 4.4.3
- Change first title line that says "QTextEdit" to align all the way
to the left. - Place cursor on first position on first line.
- Paste some text before the word "QTextEdit".
- Now, select undo.
- Cursor should have been placed back at position 0,0.
- But it is not, it is placed at the beginning of the next line
These are reproducible with Qt4.4 on Vista.
Attachments
Issue Links
- is duplicated by
-
QTBUG-31219 QTextDocument::contentsChange() bad parameters
-
- Closed
-
-
QTBUG-48814 Incorrect lengths reported by QTextDocument::contentsChange when pasting and clearing
-
- Closed
-