// QTextCursor::select(QTextCursor::WordUnderCursor) does not work properly.
// When the cursor is positioned in the spaces group between two words,
// this call selects the previous word instead of selecting nothing.
// WinXP X64 (SP2) EN + Qt4.6.2 + Qt Creator 1.3.1 +
// gcc4.4 (from ftp://ftp.qt.nokia.com/misc/MinGW-gcc440_1.zip)
#include <QtGui>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
QTextEdit* textEdit = new QTextEdit;
textEdit->setText("Hello World");
textEdit->setHtml(textEdit->toHtml()); // just to preserve spaces between words
textEdit->show();
QTextCursor cursor = textEdit->textCursor();
cursor.setPosition(15, QTextCursor::MoveAnchor);
// Set the cursor 10 spaces after the word "Hello"
// and 10 spaces before the word "World".
cursor.select(QTextCursor::WordUnderCursor);
textEdit->setTextCursor(cursor);
// This piece of code selects the first word "Hello",
// but it should select nothing
return a.exec();
}
Прошу пользователей форума посмотреть, повторяется ли у них этот баг или нет.
P.S. Или я несколько недопонял смысл QTextCursor::WordUnderCursor?