#include #include #include #include #include #include "sminputdialog.h" SmInputDialog::SmInputDialog(const QString &label, QWidget *parent) : QDialog(parent){ QLabel *thisL = new QLabel(label); mLE = new QLineEdit; QPushButton *cancelPB = new QPushButton(tr("Cancel")); connect(cancelPB, &QPushButton::clicked, this, &SmInputDialog::reject); QPushButton *acceptPB = new QPushButton(tr("OK")); connect(acceptPB, &QPushButton::clicked, this, &SmInputDialog::accept); QHBoxLayout *topL = new QHBoxLayout; topL->addWidget(thisL); topL->addWidget(mLE); QHBoxLayout *buttonLayout = new QHBoxLayout; buttonLayout->addStretch(); buttonLayout->addWidget(cancelPB); buttonLayout->addWidget(acceptPB); QVBoxLayout *mainLayout = new QVBoxLayout; mainLayout->addLayout(topL); mainLayout->addLayout(buttonLayout); setLayout(mainLayout); } void SmInputDialog::setText(QString &text){ mLE->setText(text); } void SmInputDialog::setCompleter(QCompleter *completer){ mLE->completer()->deleteLater(); mLE->setCompleter(completer); }