Qt 6.x
The Qt SDK
Loading...
Searching...
No Matches
qinputdialog.cpp
Go to the documentation of this file.
1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#include "qinputdialog.h"
5
6#include "qapplication.h"
7#include "qcombobox.h"
8#include "qdialogbuttonbox.h"
9#include "qlabel.h"
10#include "qlayout.h"
11#include "qlineedit.h"
12#include "qplaintextedit.h"
13#include "qlistview.h"
14#include "qpushbutton.h"
15#include "qspinbox.h"
16#include "qstackedlayout.h"
17#include "qvalidator.h"
18#include "qevent.h"
19#include "qdialog_p.h"
20
22
27
29};
30
31static const char *candidateSignal(int which)
32{
33 switch (CandidateSignal(which)) {
34 case TextValueSelectedSignal: return SIGNAL(textValueSelected(QString));
35 case IntValueSelectedSignal: return SIGNAL(intValueSelected(int));
36 case DoubleValueSelectedSignal: return SIGNAL(doubleValueSelected(double));
37
39 break;
40 };
41 Q_UNREACHABLE_RETURN(nullptr);
42}
43
44static const char *signalForMember(const char *member)
45{
46 QByteArray normalizedMember(QMetaObject::normalizedSignature(member));
47
48 for (int i = 0; i < NumCandidateSignals; ++i)
49 if (QMetaObject::checkConnectArgs(candidateSignal(i), normalizedMember))
50 return candidateSignal(i);
51
52 // otherwise, use fit-all accepted signal:
53 return SIGNAL(accepted());
54}
55
57
58/*
59 These internal classes add extra validation to QSpinBox and QDoubleSpinBox by emitting
60 textChanged(bool) after events that may potentially change the visible text. Return or
61 Enter key presses are not propagated if the visible text is invalid. Instead, the visible
62 text is modified to the last valid value.
63*/
65{
67
68public:
70 : QSpinBox(parent) {
71 connect(lineEdit(), SIGNAL(textChanged(QString)), this, SLOT(notifyTextChanged()));
72 connect(this, SIGNAL(editingFinished()), this, SLOT(notifyTextChanged()));
73 }
74
76 void textChanged(bool);
77
78private slots:
79 void notifyTextChanged() { emit textChanged(hasAcceptableInput()); }
80
81private:
82 void keyPressEvent(QKeyEvent *event) override {
83 if ((event->key() == Qt::Key_Return || event->key() == Qt::Key_Enter) && !hasAcceptableInput()) {
84 setProperty("value", property("value"));
85 } else {
87 }
88 notifyTextChanged();
89 }
90
93 notifyTextChanged();
94 }
95};
96
98{
100
101public:
104 connect(lineEdit(), SIGNAL(textChanged(QString)), this, SLOT(notifyTextChanged()));
105 connect(this, SIGNAL(editingFinished()), this, SLOT(notifyTextChanged()));
106 }
107
108signals:
109 void textChanged(bool);
110
111private slots:
112 void notifyTextChanged() { emit textChanged(hasAcceptableInput()); }
113
114private:
115 void keyPressEvent(QKeyEvent *event) override {
116 if ((event->key() == Qt::Key_Return || event->key() == Qt::Key_Enter) && !hasAcceptableInput()) {
117 setProperty("value", property("value"));
118 } else {
120 }
121 notifyTextChanged();
122 }
123
126 notifyTextChanged();
127 }
128};
129
131{
132public:
135 {
136 if (query == Qt::ImEnabled)
137 return false;
139 }
140};
141
143{
144 Q_DECLARE_PUBLIC(QInputDialog)
145
146public:
148
149 void ensureLayout();
150 void ensureLineEdit();
151 void ensurePlainTextEdit();
152 void ensureComboBox();
153 void ensureListView();
154 void ensureIntSpinBox();
155 void ensureDoubleSpinBox();
159 void setComboBoxText(const QString &text);
160 void setListViewText(const QString &text);
161 QString listViewText() const;
162 void ensureLayout() const { const_cast<QInputDialogPrivate *>(this)->ensureLayout(); }
163 bool useComboBoxOrListView() const { return comboBox && comboBox->count() > 0; }
164 void _q_textChanged(const QString &text);
166 void _q_currentRowChanged(const QModelIndex &newIndex, const QModelIndex &oldIndex);
167
168 mutable QLabel *label;
178 QInputDialog::InputDialogOptions opts;
182};
183
185 : label(nullptr), buttonBox(nullptr), lineEdit(nullptr), plainTextEdit(nullptr), intSpinBox(nullptr), doubleSpinBox(nullptr),
186 comboBox(nullptr), listView(nullptr), inputWidget(nullptr), mainLayout(nullptr)
187{
188}
189
191{
192 Q_Q(QInputDialog);
193
194 if (mainLayout)
195 return;
196
197 if (!inputWidget) {
200 }
201
202 if (!label)
203 label = new QLabel(QInputDialog::tr("Enter a value:"), q);
204#ifndef QT_NO_SHORTCUT
205 label->setBuddy(inputWidget);
206#endif
208
210 QObject::connect(buttonBox, SIGNAL(accepted()), q, SLOT(accept()));
211 QObject::connect(buttonBox, SIGNAL(rejected()), q, SLOT(reject()));
212
213 mainLayout = new QVBoxLayout(q);
218 ensureEnabledConnection(qobject_cast<QAbstractSpinBox *>(inputWidget));
219 inputWidget->show();
220}
221
223{
224 Q_Q(QInputDialog);
225 if (!lineEdit) {
226 lineEdit = new QLineEdit(q);
227#ifndef QT_NO_IM
229#endif
230 lineEdit->hide();
233 }
234}
235
237{
238 Q_Q(QInputDialog);
239 if (!plainTextEdit) {
242#ifndef QT_NO_IM
244#endif
245 plainTextEdit->hide();
248 }
249}
250
252{
253 Q_Q(QInputDialog);
254 if (!comboBox) {
255 comboBox = new QComboBox(q);
256#ifndef QT_NO_IM
258#endif
259 comboBox->hide();
260 QObject::connect(comboBox, SIGNAL(editTextChanged(QString)),
262 QObject::connect(comboBox, SIGNAL(currentTextChanged(QString)),
264 }
265}
266
268{
269 Q_Q(QInputDialog);
270 if (!listView) {
273 listView->hide();
279 SIGNAL(currentRowChanged(QModelIndex,QModelIndex)),
281 }
282}
283
285{
286 Q_Q(QInputDialog);
287 if (!intSpinBox) {
289 intSpinBox->hide();
290 QObject::connect(intSpinBox, SIGNAL(valueChanged(int)),
291 q, SIGNAL(intValueChanged(int)));
292 }
293}
294
296{
297 Q_Q(QInputDialog);
298 if (!doubleSpinBox) {
301 QObject::connect(doubleSpinBox, SIGNAL(valueChanged(double)),
302 q, SIGNAL(doubleValueChanged(double)));
303 }
304}
305
307{
308 if (spinBox) {
310 QObject::connect(spinBox, SIGNAL(textChanged(bool)), okButton, SLOT(setEnabled(bool)), Qt::UniqueConnection);
311 }
312}
313
315{
317 if (inputWidget == widget)
318 return;
319
320 if (mainLayout) {
323 inputWidget->hide();
325 widget->show();
326
327 // disconnect old input widget
329 if (QAbstractSpinBox *spinBox = qobject_cast<QAbstractSpinBox *>(inputWidget))
330 QObject::disconnect(spinBox, SIGNAL(textChanged(bool)), okButton, SLOT(setEnabled(bool)));
331
332 // connect new input widget and update enabled state of OK button
333 QAbstractSpinBox *spinBox = qobject_cast<QAbstractSpinBox *>(widget);
336 }
337
339
340 // synchronize the text shown in the new text editor with the current
341 // textValue
342 if (widget == lineEdit) {
344 } else if (widget == plainTextEdit) {
346 } else if (widget == comboBox) {
348 } else if (widget == listView) {
350 ensureLayout();
352 }
353}
354
356{
358
359 if (useComboBoxOrListView()) {
363 } else {
365 }
369 } else {
372 }
373
375
376 if (inputWidget == comboBox) {
378 } else if (inputWidget == listView) {
380 }
381}
382
384{
385 int index = comboBox->findText(text);
386 if (index != -1) {
388 } else if (comboBox->isEditable()) {
390 }
391}
392
394{
395 int row = comboBox->findText(text);
396 if (row != -1) {
400 }
401}
402
404{
407 return comboBox->itemText(row);
408 } else {
409 return QString();
410 }
411}
412
414{
415 Q_Q(QInputDialog);
416 if (textValue != text) {
417 textValue = text;
418 emit q->textValueChanged(text);
419 }
420}
421
423{
424 Q_Q(QInputDialog);
426 if (textValue != text) {
427 textValue = text;
428 emit q->textValueChanged(text);
429 }
430}
431
433 const QModelIndex & /* oldIndex */)
434{
435 _q_textChanged(comboBox->model()->data(newIndex).toString());
437}
438
488{
489}
490
497{
498}
499
511{
512 Q_D(QInputDialog);
513
515
516 /*
517 Warning: Some functions in QInputDialog rely on implementation details
518 of the code below. Look for the comments that accompany the calls to
519 setInputMode() throughout this file before you change the code below.
520 */
521
522 switch (mode) {
523 case IntInput:
524 d->ensureIntSpinBox();
525 widget = d->intSpinBox;
526 break;
527 case DoubleInput:
528 d->ensureDoubleSpinBox();
529 widget = d->doubleSpinBox;
530 break;
531 default:
533 d->chooseRightTextInputWidget();
534 return;
535 }
536
537 d->setInputWidget(widget);
538}
539
541{
542 Q_D(const QInputDialog);
543
544 if (d->inputWidget) {
545 if (d->inputWidget == d->intSpinBox) {
546 return IntInput;
547 } else if (d->inputWidget == d->doubleSpinBox) {
548 return DoubleInput;
549 }
550 }
551
552 return TextInput;
553}
554
563{
564 Q_D(QInputDialog);
565 if (!d->label) {
566 d->label = new QLabel(text, this);
567 } else {
568 d->label->setText(text);
569 }
570}
571
573{
574 Q_D(const QInputDialog);
575 d->ensureLayout();
576 return d->label->text();
577}
578
603{
604 Q_D(QInputDialog);
605 if (!(d->opts & option) != !on)
606 setOptions(d->opts ^ option);
607}
608
616{
617 Q_D(const QInputDialog);
618 return (d->opts & option) != 0;
619}
620
630void QInputDialog::setOptions(InputDialogOptions options)
631{
632 Q_D(QInputDialog);
633
634 InputDialogOptions changed = (options ^ d->opts);
635 if (!changed)
636 return;
637
638 d->opts = options;
639 d->ensureLayout();
640
641 if (changed & NoButtons)
642 d->buttonBox->setVisible(!(options & NoButtons));
643 if ((changed & UseListViewForComboBoxItems) && inputMode() == TextInput)
644 d->chooseRightTextInputWidget();
645 if ((changed & UsePlainTextEditForTextInput) && inputMode() == TextInput)
646 d->chooseRightTextInputWidget();
647}
648
649QInputDialog::InputDialogOptions QInputDialog::options() const
650{
651 Q_D(const QInputDialog);
652 return d->opts;
653}
654
666{
667 Q_D(QInputDialog);
668
670 if (d->inputWidget == d->lineEdit) {
671 d->lineEdit->setText(text);
672 } else if (d->inputWidget == d->plainTextEdit) {
673 d->plainTextEdit->setPlainText(text);
674 } else if (d->inputWidget == d->comboBox) {
675 d->setComboBoxText(text);
676 } else {
677 d->setListViewText(text);
678 }
679}
680
682{
683 Q_D(const QInputDialog);
684 return d->textValue;
685}
686
698{
699 Q_D(QInputDialog);
700 d->ensureLineEdit();
701 d->lineEdit->setEchoMode(mode);
702}
703
705{
706 Q_D(const QInputDialog);
707 if (d->lineEdit) {
708 return d->lineEdit->echoMode();
709 } else {
710 return QLineEdit::Normal;
711 }
712}
713
722{
723 Q_D(QInputDialog);
724 d->ensureComboBox();
725 d->comboBox->setEditable(editable);
726 if (inputMode() == TextInput)
727 d->chooseRightTextInputWidget();
728}
729
731{
732 Q_D(const QInputDialog);
733 if (d->comboBox) {
734 return d->comboBox->isEditable();
735 } else {
736 return false;
737 }
738}
739
748{
749 Q_D(QInputDialog);
750
751 d->ensureComboBox();
752 {
753 const QSignalBlocker blocker(d->comboBox);
754 d->comboBox->clear();
755 d->comboBox->addItems(items);
756 }
757
758 if (inputMode() == TextInput)
759 d->chooseRightTextInputWidget();
760}
761
763{
764 Q_D(const QInputDialog);
766 if (d->comboBox) {
767 const int count = d->comboBox->count();
768 result.reserve(count);
769 for (int i = 0; i < count; ++i)
770 result.append(d->comboBox->itemText(i));
771 }
772 return result;
773}
774
784{
785 Q_D(QInputDialog);
787 d->intSpinBox->setValue(value);
788}
789
791{
792 Q_D(const QInputDialog);
793 if (d->intSpinBox) {
794 return d->intSpinBox->value();
795 } else {
796 return 0;
797 }
798}
799
809{
810 Q_D(QInputDialog);
811 d->ensureIntSpinBox();
812 d->intSpinBox->setMinimum(min);
813}
814
816{
817 Q_D(const QInputDialog);
818 if (d->intSpinBox) {
819 return d->intSpinBox->minimum();
820 } else {
821 return 0;
822 }
823}
824
834{
835 Q_D(QInputDialog);
836 d->ensureIntSpinBox();
837 d->intSpinBox->setMaximum(max);
838}
839
841{
842 Q_D(const QInputDialog);
843 if (d->intSpinBox) {
844 return d->intSpinBox->maximum();
845 } else {
846 return 99;
847 }
848}
849
855void QInputDialog::setIntRange(int min, int max)
856{
857 Q_D(QInputDialog);
858 d->ensureIntSpinBox();
859 d->intSpinBox->setRange(min, max);
860}
861
871{
872 Q_D(QInputDialog);
873 d->ensureIntSpinBox();
874 d->intSpinBox->setSingleStep(step);
875}
876
878{
879 Q_D(const QInputDialog);
880 if (d->intSpinBox) {
881 return d->intSpinBox->singleStep();
882 } else {
883 return 1;
884 }
885}
886
896{
897 Q_D(QInputDialog);
899 d->doubleSpinBox->setValue(value);
900}
901
903{
904 Q_D(const QInputDialog);
905 if (d->doubleSpinBox) {
906 return d->doubleSpinBox->value();
907 } else {
908 return 0.0;
909 }
910}
911
921{
922 Q_D(QInputDialog);
923 d->ensureDoubleSpinBox();
924 d->doubleSpinBox->setMinimum(min);
925}
926
928{
929 Q_D(const QInputDialog);
930 if (d->doubleSpinBox) {
931 return d->doubleSpinBox->minimum();
932 } else {
933 return 0.0;
934 }
935}
936
946{
947 Q_D(QInputDialog);
948 d->ensureDoubleSpinBox();
949 d->doubleSpinBox->setMaximum(max);
950}
951
953{
954 Q_D(const QInputDialog);
955 if (d->doubleSpinBox) {
956 return d->doubleSpinBox->maximum();
957 } else {
958 return 99.99;
959 }
960}
961
967void QInputDialog::setDoubleRange(double min, double max)
968{
969 Q_D(QInputDialog);
970 d->ensureDoubleSpinBox();
971 d->doubleSpinBox->setRange(min, max);
972}
973
984{
985 Q_D(QInputDialog);
986 d->ensureDoubleSpinBox();
987 d->doubleSpinBox->setDecimals(decimals);
988}
989
991{
992 Q_D(const QInputDialog);
993 if (d->doubleSpinBox) {
994 return d->doubleSpinBox->decimals();
995 } else {
996 return 2;
997 }
998}
999
1008{
1009 Q_D(const QInputDialog);
1010 d->ensureLayout();
1011 d->buttonBox->button(QDialogButtonBox::Ok)->setText(text);
1012}
1013
1015{
1016 Q_D(const QInputDialog);
1017 d->ensureLayout();
1018 return d->buttonBox->button(QDialogButtonBox::Ok)->text();
1019}
1020
1028{
1029 Q_D(const QInputDialog);
1030 d->ensureLayout();
1031 d->buttonBox->button(QDialogButtonBox::Cancel)->setText(text);
1032}
1033
1035{
1036 Q_D(const QInputDialog);
1037 d->ensureLayout();
1038 return d->buttonBox->button(QDialogButtonBox::Cancel)->text();
1039}
1040
1057void QInputDialog::open(QObject *receiver, const char *member)
1058{
1059 Q_D(QInputDialog);
1060 connect(this, signalForMember(member), receiver, member);
1061 d->receiverToDisconnectOnClose = receiver;
1062 d->memberToDisconnectOnClose = member;
1063 QDialog::open();
1064}
1065
1070{
1071 Q_D(const QInputDialog);
1072 d->ensureLayout();
1073 return QDialog::minimumSizeHint();
1074}
1075
1080{
1081 Q_D(const QInputDialog);
1082 d->ensureLayout();
1083 return QDialog::sizeHint();
1084}
1085
1090{
1091 Q_D(const QInputDialog);
1092 if (visible) {
1093 d->ensureLayout();
1094 d->inputWidget->setFocus();
1095 if (d->inputWidget == d->lineEdit) {
1096 d->lineEdit->selectAll();
1097 } else if (d->inputWidget == d->plainTextEdit) {
1098 d->plainTextEdit->selectAll();
1099 } else if (d->inputWidget == d->intSpinBox) {
1100 d->intSpinBox->selectAll();
1101 } else if (d->inputWidget == d->doubleSpinBox) {
1102 d->doubleSpinBox->selectAll();
1103 }
1104 }
1106}
1107
1116{
1117 Q_D(QInputDialog);
1119 if (result) {
1121 switch (mode) {
1122 case DoubleInput:
1124 break;
1125 case IntInput:
1127 break;
1128 default:
1131 }
1132 }
1133 if (d->receiverToDisconnectOnClose) {
1134 disconnect(this, signalForMember(d->memberToDisconnectOnClose),
1135 d->receiverToDisconnectOnClose, d->memberToDisconnectOnClose);
1136 d->receiverToDisconnectOnClose = nullptr;
1137 }
1138 d->memberToDisconnectOnClose.clear();
1139}
1140
1168 QLineEdit::EchoMode mode, const QString &text, bool *ok,
1169 Qt::WindowFlags flags, Qt::InputMethodHints inputMethodHints)
1170{
1174 dialog->setTextValue(text);
1175 dialog->setTextEchoMode(mode);
1177
1178 const int ret = dialog->exec();
1179 if (ok)
1180 *ok = !!ret;
1181 if (ret) {
1182 return dialog->textValue();
1183 } else {
1184 return QString();
1185 }
1186}
1187
1216 const QString &text, bool *ok, Qt::WindowFlags flags,
1217 Qt::InputMethodHints inputMethodHints)
1218{
1223 dialog->setTextValue(text);
1225
1226 const int ret = dialog->exec();
1227 if (ok)
1228 *ok = !!ret;
1229 if (ret) {
1230 return dialog->textValue();
1231 } else {
1232 return QString();
1233 }
1234}
1235
1264 int min, int max, int step, bool *ok, Qt::WindowFlags flags)
1265{
1269 dialog->setIntRange(min, max);
1270 dialog->setIntValue(value);
1271 dialog->setIntStep(step);
1272
1273 const int ret = dialog->exec();
1274 if (ok)
1275 *ok = !!ret;
1276 if (ret) {
1277 return dialog->intValue();
1278 } else {
1279 return value;
1280 }
1281}
1282
1311 double value, double min, double max, int decimals, bool *ok,
1312 Qt::WindowFlags flags, double step)
1313{
1317 dialog->setDoubleDecimals(decimals);
1318 dialog->setDoubleRange(min, max);
1319 dialog->setDoubleValue(value);
1320 dialog->setDoubleStep(step);
1321
1322 const int ret = dialog->exec();
1323 if (ok)
1324 *ok = !!ret;
1325 if (ret) {
1326 return dialog->doubleValue();
1327 } else {
1328 return value;
1329 }
1330}
1331
1362 const QStringList &items, int current, bool editable, bool *ok,
1363 Qt::WindowFlags flags, Qt::InputMethodHints inputMethodHints)
1364{
1365 QString text(items.value(current));
1366
1370 dialog->setComboBoxItems(items);
1371 dialog->setTextValue(text);
1372 dialog->setComboBoxEditable(editable);
1374
1375 const int ret = dialog->exec();
1376 if (ok)
1377 *ok = !!ret;
1378 if (ret) {
1379 return dialog->textValue();
1380 } else {
1381 return text;
1382 }
1383}
1384
1395{
1396 Q_D(QInputDialog);
1397 d->ensureDoubleSpinBox();
1398 d->doubleSpinBox->setSingleStep(step);
1399}
1400
1402{
1403 Q_D(const QInputDialog);
1404 if (d->doubleSpinBox)
1405 return d->doubleSpinBox->singleStep();
1406 else
1407 return 1.0;
1408}
1409
1474
1475#include "qinputdialog.moc"
1476#include "moc_qinputdialog.cpp"
The QAbstractButton class is the abstract base class of button widgets, providing functionality commo...
virtual Q_INVOKABLE QVariant data(const QModelIndex &index, int role=Qt::DisplayRole) const =0
Returns the data stored under the given role for the item referred to by the index.
virtual Q_INVOKABLE QModelIndex index(int row, int column, const QModelIndex &parent=QModelIndex()) const =0
Returns the index of the item in the model specified by the given row, column and parent index.
void setEditTriggers(EditTriggers triggers)
void setCurrentIndex(const QModelIndex &index)
Sets the current item to be the item at index.
virtual void setModel(QAbstractItemModel *model)
Sets the model for the view to present.
virtual QVariant inputMethodQuery(Qt::InputMethodQuery query) const override
\reimp
QItemSelectionModel * selectionModel() const
Returns the current selection model.
void setSelectionMode(QAbstractItemView::SelectionMode mode)
The QAbstractSpinBox class provides a spinbox and a line edit to display values.
void editingFinished()
This signal is emitted editing is finished.
QLineEdit * lineEdit() const
This function returns a pointer to the line edit of the spin box.
bool hasAcceptableInput() const
void addWidget(QWidget *, int stretch=0, Qt::Alignment alignment=Qt::Alignment())
Adds widget to the end of this box layout, with a stretch factor of stretch and alignment alignment.
void insertWidget(int index, QWidget *widget, int stretch=0, Qt::Alignment alignment=Qt::Alignment())
Inserts widget at position index, with stretch factor stretch and alignment alignment.
\inmodule QtCore
Definition qbytearray.h:57
The QComboBox widget is a combined button and popup list.
Definition qcombobox.h:24
QString itemText(int index) const
Returns the text for the given index in the combobox.
int count
the number of items in the combobox
Definition qcombobox.h:28
bool isEditable() const
QString currentText
the current text
Definition qcombobox.h:30
void setEditText(const QString &text)
Sets the text in the combobox's text edit.
QAbstractItemModel * model() const
Returns the model used by the combobox.
int findText(const QString &text, Qt::MatchFlags flags=static_cast< Qt::MatchFlags >(Qt::MatchExactly|Qt::MatchCaseSensitive)) const
Returns the index of the item containing the given text; otherwise returns -1.
Definition qcombobox.h:61
void setCurrentIndex(int index)
The QDialogButtonBox class is a widget that presents buttons in a layout that is appropriate to the c...
QPushButton * button(StandardButton which) const
Returns the QPushButton corresponding to the standard button which, or \nullptr if the standard butto...
The QDialog class is the base class of dialog windows.
Definition qdialog.h:19
QSize sizeHint() const override
\reimp
Definition qdialog.cpp:956
virtual int exec()
Shows the dialog as a \l{QDialog::Modal Dialogs}{modal dialog}, blocking until the user closes it.
Definition qdialog.cpp:539
QSize minimumSizeHint() const override
\reimp
Definition qdialog.cpp:972
int result() const
In general returns the modal dialog's result code, Accepted or Rejected.
Definition qdialog.cpp:471
virtual void done(int)
Closes the dialog and sets its result code to r.
Definition qdialog.cpp:598
virtual void open()
Definition qdialog.cpp:499
The QDoubleSpinBox class provides a spin box widget that takes doubles.
Definition qspinbox.h:82
void setLabelText(DialogLabel label, const QString &text)
Sets the text shown in the filedialog in the specified label.
void setOptions(Options options)
void keyPressEvent(QKeyEvent *event) override
\reimp
void mousePressEvent(QMouseEvent *event) override
\reimp
QInputDialogDoubleSpinBox(QWidget *parent=nullptr)
QInputDialogListView(QWidget *parent=nullptr)
QVariant inputMethodQuery(Qt::InputMethodQuery query) const override
\reimp
void ensureLayout() const
void _q_currentRowChanged(const QModelIndex &newIndex, const QModelIndex &oldIndex)
void setComboBoxText(const QString &text)
QPointer< QObject > receiverToDisconnectOnClose
QInputDialogListView * listView
void setInputWidget(QWidget *widget)
bool useComboBoxOrListView() const
void ensureEnabledConnection(QAbstractSpinBox *spinBox)
void setListViewText(const QString &text)
QDialogButtonBox * buttonBox
QByteArray memberToDisconnectOnClose
QInputDialog::InputDialogOptions opts
QString listViewText() const
void _q_textChanged(const QString &text)
QDoubleSpinBox * doubleSpinBox
QVBoxLayout * mainLayout
QPlainTextEdit * plainTextEdit
void textChanged(bool)
QInputDialogSpinBox(QWidget *parent)
void keyPressEvent(QKeyEvent *event) override
\reimp
void mousePressEvent(QMouseEvent *event) override
\reimp
The QInputDialog class provides a simple convenience dialog to get a single value from the user.
void setDoubleMaximum(double max)
QString cancelButtonText() const
the text for the button used to cancel the dialog
void setTextValue(const QString &text)
int doubleDecimals() const
sets the precision of the double spinbox in decimals
QString okButtonText() const
the text for the button used to accept the entry in the dialog
InputDialogOptions options() const
the various options that affect the look and feel of the dialog
void setDoubleValue(double value)
int intValue() const
the current integer value accepted as input
void setDoubleRange(double min, double max)
Sets the range of double precision floating point values accepted by the dialog when used in DoubleIn...
double doubleMaximum() const
the maximum double precision floating point value accepted as input
QSize sizeHint() const override
\reimp
static QString getItem(QWidget *parent, const QString &title, const QString &label, const QStringList &items, int current=0, bool editable=true, bool *ok=nullptr, Qt::WindowFlags flags=Qt::WindowFlags(), Qt::InputMethodHints inputMethodHints=Qt::ImhNone)
Static convenience function to let the user select an item from a string list.
void setCancelButtonText(const QString &text)
double doubleMinimum() const
the minimum double precision floating point value accepted as input
InputMode inputMode() const
the mode used for input
void setIntMaximum(int max)
QInputDialog(QWidget *parent=nullptr, Qt::WindowFlags flags=Qt::WindowFlags())
void setOption(InputDialogOption option, bool on=true)
Sets the given option to be enabled if on is true; otherwise, clears the given option.
void intValueSelected(int value)
This signal is emitted whenever the user selects a integer value by accepting the dialog; for example...
void setIntStep(int step)
void setComboBoxItems(const QStringList &items)
static QString getText(QWidget *parent, const QString &title, const QString &label, QLineEdit::EchoMode echo=QLineEdit::Normal, const QString &text=QString(), bool *ok=nullptr, Qt::WindowFlags flags=Qt::WindowFlags(), Qt::InputMethodHints inputMethodHints=Qt::ImhNone)
Static convenience function to get a string from the user.
void textValueSelected(const QString &text)
This signal is emitted whenever the user selects a text string by accepting the dialog; for example,...
int intStep() const
the step by which the integer value is increased and decreased
double doubleValue() const
the current double precision floating point value accepted as input
static QString getMultiLineText(QWidget *parent, const QString &title, const QString &label, const QString &text=QString(), bool *ok=nullptr, Qt::WindowFlags flags=Qt::WindowFlags(), Qt::InputMethodHints inputMethodHints=Qt::ImhNone)
void setTextEchoMode(QLineEdit::EchoMode mode)
QStringList comboBoxItems() const
the items used in the combo box for the input dialog
void setDoubleStep(double step)
void setComboBoxEditable(bool editable)
int intMinimum() const
the minimum integer value accepted as input
double doubleStep() const
the step by which the double value is increased and decreased
void setInputMode(InputMode mode)
bool isComboBoxEditable() const
void setOptions(InputDialogOptions options)
void setIntValue(int value)
void setDoubleDecimals(int decimals)
static int getInt(QWidget *parent, const QString &title, const QString &label, int value=0, int minValue=-2147483647, int maxValue=2147483647, int step=1, bool *ok=nullptr, Qt::WindowFlags flags=Qt::WindowFlags())
void setLabelText(const QString &text)
bool testOption(InputDialogOption option) const
Returns true if the given option is enabled; otherwise, returns false.
void setIntRange(int min, int max)
Sets the range of integer values accepted by the dialog when used in IntInput mode,...
QLineEdit::EchoMode textEchoMode() const
the echo mode for the text value
int intMaximum() const
the maximum integer value accepted as input
void doubleValueSelected(double value)
This signal is emitted whenever the user selects a double value by accepting the dialog; for example,...
void setIntMinimum(int min)
void setOkButtonText(const QString &text)
void setDoubleMinimum(double min)
@ UseListViewForComboBoxItems
@ UsePlainTextEditForTextInput
QSize minimumSizeHint() const override
\reimp
virtual void open()
Definition qdialog.cpp:499
QString textValue() const
the text value for the input dialog
static double getDouble(QWidget *parent, const QString &title, const QString &label, double value=0, double minValue=-2147483647, double maxValue=2147483647, int decimals=1, bool *ok=nullptr, Qt::WindowFlags flags=Qt::WindowFlags(), double step=1)
Static convenience function to get a floating point number from the user.
QString labelText() const
the label's text which describes what needs to be input
Q_INVOKABLE QModelIndexList selectedRows(int column=0) const
virtual void setCurrentIndex(const QModelIndex &index, QItemSelectionModel::SelectionFlags command)
Sets the model item index to be the current item, and emits currentChanged().
The QKeyEvent class describes a key event.
Definition qevent.h:423
The QLabel widget provides a text or image display.
Definition qlabel.h:20
void removeWidget(QWidget *w)
Removes the widget widget from the layout.
Definition qlayout.cpp:1322
void setSizeConstraint(SizeConstraint)
Definition qlayout.cpp:1240
@ SetMinAndMaxSize
Definition qlayout.h:41
The QLineEdit widget is a one-line text editor.
Definition qlineedit.h:28
void setText(const QString &)
EchoMode
This enum type describes how a line edit should display its contents.
Definition qlineedit.h:77
The QListView class provides a list or icon view onto a model.
Definition qlistview.h:17
T value(qsizetype i) const
Definition qlist.h:661
\inmodule QtCore
constexpr int row() const noexcept
Returns the row this model index refers to.
\inmodule QtGui
Definition qevent.h:195
\inmodule QtCore
Definition qobject.h:90
QObject * parent() const
Returns a pointer to the parent object.
Definition qobject.h:311
static QMetaObject::Connection connect(const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
\threadsafe
Definition qobject.cpp:2823
static bool disconnect(const QObject *sender, const char *signal, const QObject *receiver, const char *member)
\threadsafe
Definition qobject.cpp:3099
The QPlainTextEdit class provides a widget that is used to edit and display plain text.
void setLineWrapMode(LineWrapMode mode)
void setPlainText(const QString &text)
Changes the text of the text edit to the string text.
QString toPlainText() const
Returns the text of the text edit as plain text.
\inmodule QtCore
Definition qpointer.h:18
Exception-safe wrapper around QObject::blockSignals().
Definition qobject.h:443
\inmodule QtCore
Definition qsize.h:25
The QSpinBox class provides a spin box widget.
Definition qspinbox.h:16
\inmodule QtCore
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:127
The QVBoxLayout class lines up widgets vertically.
Definition qboxlayout.h:91
\inmodule QtCore
Definition qvariant.h:64
QString toString() const
Returns the variant as a QString if the variant has a userType() including, but not limited to:
uint inheritsInputMethodHints
Definition qwidget_p.h:722
The QWidget class is the base class of all user interface objects.
Definition qwidget.h:99
void setEnabled(bool)
Definition qwidget.cpp:3365
virtual void mousePressEvent(QMouseEvent *event)
This event handler, for event event, can be reimplemented in a subclass to receive mouse press events...
Definition qwidget.cpp:9529
void hide()
Hides the widget.
Definition qwidget.cpp:8209
void show()
Shows the widget and its child widgets.
Definition qwidget.cpp:7956
virtual void setVisible(bool visible)
Definition qwidget.cpp:8329
Qt::InputMethodHints inputMethodHints
What input method specific hints the widget has.
Definition qwidget.h:178
void setWindowTitle(const QString &)
Definition qwidget.cpp:6109
virtual void keyPressEvent(QKeyEvent *event)
This event handler, for event event, can be reimplemented in a subclass to receive key press events f...
Definition qwidget.cpp:9652
void setInputMethodHints(Qt::InputMethodHints hints)
bool visible
whether the widget is visible
Definition qwidget.h:144
QOpenGLWidget * widget
[1]
QString text
object setProperty("down", true)
void textChanged(const QString &newText)
Combined button and popup list for selecting options.
InputMethodQuery
@ ImEnabled
@ Horizontal
Definition qnamespace.h:98
@ Key_Return
Definition qnamespace.h:662
@ Key_Enter
Definition qnamespace.h:663
@ UniqueConnection
EGLOutputLayerEXT EGLint EGLAttrib value
[5]
static const char * signalForMember(const char *member)
CandidateSignal
@ IntValueSelectedSignal
@ DoubleValueSelectedSignal
@ TextValueSelectedSignal
@ NumCandidateSignals
static const char * candidateSignal(int which)
return ret
#define SLOT(a)
Definition qobjectdefs.h:51
#define SIGNAL(a)
Definition qobjectdefs.h:52
GLenum mode
GLuint index
[2]
GLenum GLenum GLsizei count
GLuint GLsizei const GLchar * label
[43]
GLbitfield flags
struct _cl_event * event
GLenum query
GLdouble GLdouble GLdouble GLdouble q
Definition qopenglext.h:259
GLenum GLenum GLsizei void * row
GLuint64EXT * result
[6]
GLuint GLenum option
#define Q_ASSERT(cond)
Definition qrandom.cpp:47
#define Q_OBJECT
#define slots
#define signals
#define emit
Q_WIDGETS_EXPORT QWidgetPrivate * qt_widget_private(QWidget *widget)
const char property[13]
Definition qwizard.cpp:101
connect(quitButton, &QPushButton::clicked, &app, &QCoreApplication::quit, Qt::QueuedConnection)
QObject::connect nullptr
QLineEdit * lineEdit
QListView * listView
QString title
[35]
myObject disconnect()
[26]
QFileDialog dialog(this)
[1]
QList< QTreeWidgetItem * > items
QSpinBox * spinBox
[0]
static QByteArray normalizedSignature(const char *method)
Normalizes the signature of the given method.
static bool checkConnectArgs(const char *signal, const char *method)
Returns true if the signal and method arguments are compatible; otherwise returns false.
IUIAutomationTreeWalker __RPC__deref_out_opt IUIAutomationElement ** parent