[Interest] Editable QComboBox: lineEdit->selectAll() changes currentIndex()
André Hartmann
andre.hartmann at iseg-hv.de
Thu Sep 11 09:09:30 CEST 2014
Hi all,
The following happens with Qt 4.8.2 and 5.2.0 under Windows 7.
I have a QMainWindow with a QComboBox list, a QPushButton enter
and a QTextEdit log (see snippet below).
The combo box has insertPolicy = insertAtBottom and duplicatesEnabled =
false and is empty.
Now the following happens:
1. Input "111" and press key return -> "111" appears in the log
2. Input "222" and press key return -> "222" appears in the log
3. Choose "111" again (key line up), press key return ->
"111" appears in the log
4. "111" is still shown in the combo box, but when I press return ->
"222" appears in the log and is also the text selected in the
combo box.
As soon as I comment out ui->list->lineEdit()->selectAll(), everything
is fine.
Am I doing something wrong or is this a bug?
Andre
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <QLineEdit>
#include <QTimer>
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
connect(ui->list->lineEdit(), SIGNAL(returnPressed()),
this, SLOT(on_enter_clicked()));
}
MainWindow::~MainWindow()
{
delete ui;
}
void MainWindow::on_enter_clicked()
{
ui->log->append(ui->list->currentText());
ui->list->lineEdit()->selectAll();
ui->list->setFocus();
}
More information about the Interest
mailing list