#include <QtWidgets>
int main(int argc, char **argv) {
l->addWidget(le1);
l->addWidget(le2);
le1->setCompleter(cpl);
le2->setCompleter(cpl);
QStringListModel model
({"abcde",
"abcdef",
"abcdefg",
"klmno",
"klmnopq",
"klmnopqr"});
cpl->setModel(&model);
QObject::connect(le1,
SIGNAL(returnPressed
()), cpl,
SLOT(complete
()));
QObject::connect(le2,
SIGNAL(returnPressed
()), cpl,
SLOT(complete
()));
le1->setText("abc");
le2->setText("klm");
w.show();
return app.exec();
}
#include <QtWidgets>
int main(int argc, char **argv) {
QApplication app(argc, argv);
QWidget w;
QVBoxLayout *l = new QVBoxLayout(&w);
QLineEdit *le1 = new QLineEdit;
QLineEdit *le2 = new QLineEdit;
l->addWidget(le1);
l->addWidget(le2);
QCompleter *cpl = new QCompleter(&w);
le1->setCompleter(cpl);
le2->setCompleter(cpl);
QStringListModel model({"abcde", "abcdef", "abcdefg", "klmno", "klmnopq", "klmnopqr"});
cpl->setModel(&model);
QObject::connect(le1, SIGNAL(returnPressed()), cpl, SLOT(complete()));
QObject::connect(le2, SIGNAL(returnPressed()), cpl, SLOT(complete()));
le1->setText("abc");
le2->setText("klm");
w.show();
return app.exec();
}
To copy to clipboard, switch view to plain text mode
Bookmarks