diff options
author | Arno <arno@disconnect.de> | 2024-11-09 13:17:26 +0100 |
---|---|---|
committer | Arno <arno@disconnect.de> | 2024-11-09 13:17:26 +0100 |
commit | 6a60dd9a73cf336a67fdce4f8e067953c765fad9 (patch) | |
tree | ad9ca57296e94b1b795aa588e338d07110b6e1eb /sminputdialog.cpp | |
parent | 714bca79318b828c3ca8af1c9a4e7a65ad5fa578 (diff) | |
download | SheMov-6a60dd9a73cf336a67fdce4f8e067953c765fad9.tar.gz SheMov-6a60dd9a73cf336a67fdce4f8e067953c765fad9.tar.bz2 SheMov-6a60dd9a73cf336a67fdce4f8e067953c765fad9.zip |
Fix handling of QCompleter in SmInputDialog
setCompleter() assumed that QLineEdit always had a valid completer and
schedule it for later deletion. This caused random crashes when there
was no deleter. So make sure that mLE always a valid deleter and set the
model instead of a new completer.
Diffstat (limited to 'sminputdialog.cpp')
-rw-r--r-- | sminputdialog.cpp | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/sminputdialog.cpp b/sminputdialog.cpp index f078141..ecd43c2 100644 --- a/sminputdialog.cpp +++ b/sminputdialog.cpp @@ -3,12 +3,15 @@ #include <QCompleter> #include <QHBoxLayout> #include <QVBoxLayout> +#include <QStringListModel> #include "sminputdialog.h" SmInputDialog::SmInputDialog(const QString &label, QWidget *parent) : QDialog(parent){ QLabel *thisL = new QLabel(label); mLE = new QLineEdit; + mCompleter = new QCompleter(this); + mLE->setCompleter(mCompleter); QPushButton *cancelPB = new QPushButton(tr("Cancel")); connect(cancelPB, &QPushButton::clicked, this, &SmInputDialog::reject); QPushButton *acceptPB = new QPushButton(tr("OK")); @@ -30,7 +33,6 @@ void SmInputDialog::setText(QString &text){ mLE->setText(text); } -void SmInputDialog::setCompleter(QCompleter *completer){ - mLE->completer()->deleteLater(); - mLE->setCompleter(completer); +void SmInputDialog::setCompleterModel(const QStringList &model){ + mCompleter->setModel(new QStringListModel(model)); } |