44 #ifndef QT_NO_INPUTDIALOG 64 static const int NumCandidates = 4;
65 static const char *
const candidateSignals[NumCandidates] = {
67 SIGNAL(intValueSelected(
int)),
68 SIGNAL(doubleValueSelected(
double)),
75 while (i < NumCandidates - 1) {
80 return candidateSignals[i];
111 #ifndef QT_NO_PROPERTIES 146 #ifndef QT_NO_PROPERTIES 162 #include "qinputdialog.moc" 173 void ensureLineEdit();
174 void ensureComboBox();
175 void ensureListView();
176 void ensureIntSpinBox();
177 void ensureDoubleSpinBox();
180 void chooseRightTextInputWidget();
182 void setListViewText(
const QString &text);
186 void _q_textChanged(
const QString &text);
198 QInputDialog::InputDialogOptions
opts;
205 : label(0), buttonBox(0),
lineEdit(0), intSpinBox(0), doubleSpinBox(0), comboBox(0), listView(0),
206 inputWidget(0), mainLayout(0)
224 #ifndef QT_NO_SHORTCUT 302 q,
SIGNAL(intValueChanged(
int)));
313 q,
SIGNAL(doubleValueChanged(
double)));
424 emit q->textValueChanged(text);
535 d->ensureIntSpinBox();
536 widget =
d->intSpinBox;
539 d->ensureDoubleSpinBox();
540 widget =
d->doubleSpinBox;
544 d->chooseRightTextInputWidget();
548 d->setInputWidget(widget);
555 if (
d->inputWidget) {
556 if (
d->inputWidget ==
d->intSpinBox) {
558 }
else if (
d->inputWidget ==
d->doubleSpinBox) {
580 d->label =
new QLabel(text,
this);
582 d->label->setText(text);
585 d->label->setWordWrap(
true);
593 return d->label->text();
623 if (!(
d->opts & option) != !on)
636 return (
d->opts & option) != 0;
655 InputDialogOptions changed = (options ^
d->opts);
663 d->buttonBox->setVisible(!(options & NoButtons));
665 d->chooseRightTextInputWidget();
692 if (
d->inputWidget ==
d->lineEdit) {
693 d->lineEdit->setText(text);
694 }
else if (
d->inputWidget ==
d->comboBox) {
695 d->setComboBoxText(text);
697 d->setListViewText(text);
724 d->lineEdit->setEchoMode(mode);
731 return d->lineEdit->echoMode();
751 d->comboBox->setEditable(editable);
753 d->chooseRightTextInputWidget();
760 return d->comboBox->isEditable();
781 d->comboBox->blockSignals(
true);
782 d->comboBox->clear();
783 d->comboBox->addItems(items);
784 d->comboBox->blockSignals(
false);
787 d->chooseRightTextInputWidget();
795 const int count =
d->comboBox->count();
796 for (
int i = 0; i < count; ++i)
797 result.
append(
d->comboBox->itemText(i));
817 d->intSpinBox->setValue(value);
824 return d->intSpinBox->value();
844 d->ensureIntSpinBox();
845 d->intSpinBox->setMinimum(min);
852 return d->intSpinBox->minimum();
872 d->ensureIntSpinBox();
873 d->intSpinBox->setMaximum(max);
880 return d->intSpinBox->maximum();
894 d->ensureIntSpinBox();
895 d->intSpinBox->setRange(min, max);
912 d->ensureIntSpinBox();
913 d->intSpinBox->setSingleStep(step);
920 return d->intSpinBox->singleStep();
941 d->doubleSpinBox->setValue(value);
947 if (
d->doubleSpinBox) {
948 return d->doubleSpinBox->value();
968 d->ensureDoubleSpinBox();
969 d->doubleSpinBox->setMinimum(min);
975 if (
d->doubleSpinBox) {
976 return d->doubleSpinBox->minimum();
996 d->ensureDoubleSpinBox();
997 d->doubleSpinBox->setMaximum(max);
1003 if (
d->doubleSpinBox) {
1004 return d->doubleSpinBox->maximum();
1018 d->ensureDoubleSpinBox();
1019 d->doubleSpinBox->setRange(min, max);
1037 d->ensureDoubleSpinBox();
1038 d->doubleSpinBox->setDecimals(decimals);
1044 if (
d->doubleSpinBox) {
1045 return d->doubleSpinBox->decimals();
1122 d->receiverToDisconnectOnClose = receiver;
1123 d->memberToDisconnectOnClose = member;
1155 d->inputWidget->setFocus();
1156 if (
d->inputWidget ==
d->lineEdit) {
1157 d->lineEdit->selectAll();
1158 }
else if (
d->inputWidget ==
d->intSpinBox) {
1159 d->intSpinBox->selectAll();
1160 }
else if (
d->inputWidget ==
d->doubleSpinBox) {
1161 d->doubleSpinBox->selectAll();
1192 if (
d->receiverToDisconnectOnClose) {
1194 d->receiverToDisconnectOnClose,
d->memberToDisconnectOnClose);
1195 d->receiverToDisconnectOnClose = 0;
1197 d->memberToDisconnectOnClose.clear();
1241 int ret = dialog.
exec();
1257 Qt::WindowFlags flags)
1294 int min,
int max,
int step,
bool *ok, Qt::WindowFlags flags)
1303 int ret = dialog.
exec();
1343 double value,
double min,
double max,
int decimals,
bool *ok,
1344 Qt::WindowFlags flags)
1353 int ret = dialog.
exec();
1397 const QStringList &items,
int current,
bool editable,
bool *ok,
1403 dialog.setWindowTitle(title);
1404 dialog.setLabelText(label);
1405 dialog.setComboBoxItems(items);
1406 dialog.setTextValue(text);
1407 dialog.setComboBoxEditable(editable);
1408 dialog.setInputMethodHints(inputMethodHints);
1410 int ret = dialog.exec();
1414 return dialog.textValue();
1425 const QStringList &items,
int current,
bool editable,
bool *ok,
1426 Qt::WindowFlags flags)
1428 return getItem(parent, title, label, items, current, editable, ok, flags,
Qt::ImhNone);
1440 int value,
int min,
int max,
int step,
bool *ok,
1441 Qt::WindowFlags flags)
1443 return getInt(parent, title, label, value, min, max, step, ok, flags);
1577 #include "moc_qinputdialog.cpp" 1579 #endif // QT_NO_INPUTDIALOG
QModelIndexList selectedRows(int column=0) const
Returns the indexes in the given column for the rows where all columns are selected.
T qobject_cast(QObject *object)
void setSelectionMode(QAbstractItemView::SelectionMode mode)
The QKeyEvent class describes a key event.
The TextInput item displays an editable line of text.
bool event(QEvent *event)
Reimplemented Function
#define QT_END_NAMESPACE
This macro expands to.
QPointer< QWidget > widget
The QDialog class is the base class of dialog windows.
QSize minimumSizeHint() const
Reimplemented Function
int exec()
Shows the dialog as a modal dialog, blocking until the user closes it.
The QByteArray class provides an array of bytes.
void setEditTriggers(EditTriggers triggers)
bool setProperty(const char *name, const QVariant &value)
Sets the value of the object's name property to value.
QString toString() const
Returns the variant as a QString if the variant has type() String , Bool , ByteArray ...
void keyPressEvent(QKeyEvent *event)
This function handles keyboard input.
#define QT_END_INCLUDE_NAMESPACE
This macro is equivalent to QT_BEGIN_NAMESPACE.
static QString tr(const char *sourceText, const char *comment=0, int n=-1)
void setCurrentIndex(int index)
The QString class provides a Unicode character string.
void mousePressEvent(QMouseEvent *event)
Reimplemented Function
The QObject class is the base class of all Qt objects.
void addWidget(QWidget *, int stretch=0, Qt::Alignment alignment=0)
Adds widget to the end of this box layout, with a stretch factor of stretch and alignment alignment...
QString itemText(int index) const
Returns the text for the given index in the combobox.
void setCurrentIndex(const QModelIndex &index, QItemSelectionModel::SelectionFlags command)
Sets the model item index to be the current item, and emits currentChanged().
virtual void setModel(QAbstractItemModel *model)
Sets the model for the view to present.
virtual 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...
int key() const
Returns the code of the key that was pressed or released.
void append(const T &t)
Inserts value at the end of the list.
#define QT_BEGIN_NAMESPACE
This macro expands to.
EchoMode
This enum type describes how a line edit should display its contents.
void insertWidget(int index, QWidget *widget, int stretch=0, Qt::Alignment alignment=0)
Inserts widget at position index, with stretch factor stretch and alignment alignment.
static bool connect(const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
Creates a connection of the given type from the signal in the sender object to the method in the rece...
QItemSelectionModel * selectionModel() const
Returns the current selection model.
int row() const
Returns the row this model index refers to.
The QStringList class provides a list of strings.
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.
The QComboBox widget is a combined button and popup list.
QSize sizeHint() const
Reimplemented Function
void setCurrentIndex(const QModelIndex &index)
Sets the current item to be the item at index.
void editingFinished()
This signal is emitted editing is finished.
T value(int i) const
Returns the value at index position i in the list.
virtual 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.
The QAbstractSpinBox class provides a spinbox and a line edit to display values.
QAbstractItemModel * model() const
Returns the model used by the combobox.
QLineEdit * lineEdit() const
This function returns a pointer to the line edit of the spin box.
bool hasAcceptableInput() const
The QMouseEvent class contains parameters that describe a mouse event.
virtual void done(int)
Closes the dialog and sets its result code to r.
void setText(const QString &)
static bool disconnect(const QObject *sender, const char *signal, const QObject *receiver, const char *member)
Disconnects signal in object sender from method in object receiver.
bool hasSelection() const
Returns true if the selection model contains any selection ranges; otherwise returns false...
#define Q_DECLARE_PUBLIC(Class)
The QListView class provides a list or icon view onto a model.
void setBuddy(QWidget *)
Sets this label's buddy to buddy.
The QDoubleSpinBox class provides a spin box widget that takes doubles.
QObject * parent() const
Returns a pointer to the parent object.
int result() const
In general returns the modal dialog's result code, Accepted or Rejected.
The QModelIndex class is used to locate data in a data model.
The QSpinBox class provides a spin box widget.
The QLabel widget provides a text or image display.
The QLineEdit widget is a one-line text editor.
#define QT_USE_NAMESPACE
This macro expands to using QT_NAMESPACE if QT_NAMESPACE is defined and nothing otherwise.
QVariant property(const char *name) const
Returns the value of the object's name property.
#define QT_BEGIN_INCLUDE_NAMESPACE
This macro is equivalent to QT_END_NAMESPACE.
void setSizeConstraint(SizeConstraint)
void open()
Shows the dialog as a window modal dialog, returning immediately.
QString currentText
the current text
The QSize class defines the size of a two-dimensional object using integer point precision.
The QVBoxLayout class lines up widgets vertically.
void setEditText(const QString &text)
Sets the text in the combobox's text edit.
void setVisible(bool visible)
Reimplemented Function
void removeWidget(QWidget *w)
Removes the widget widget from the layout.