Old thread but I have a similar problem.
I set the selection to (0, 0) but all the text is selected anyway.
If I comment setFocus, then no text is selected (but in that case I don't need any call to setSelection(0, 0)).
#include <QtGui>
int main(int argc, char *argv[])
{
le->setText("test");
le->setFocus();
le->setSelection(0, 0);
dg->exec();
return app.exec();
}
#include <QtGui>
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
QDialog* dg = new QDialog();
QLineEdit* le = new QLineEdit(dg);
le->setText("test");
le->setFocus();
le->setSelection(0, 0);
dg->exec();
return app.exec();
}
To copy to clipboard, switch view to plain text mode
QT += gui core
TARGET = dialog
TEMPLATE = app
HEADERS =
SOURCES = main.cpp
QT += gui core
TARGET = dialog
TEMPLATE = app
HEADERS =
SOURCES = main.cpp
To copy to clipboard, switch view to plain text mode
screenshotgps.png
Bookmarks