Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

QInputDialog Class Reference

A convenience dialog to get a simple input from the user. More...

#include </home/clem/local/src/opie/libqtaux/qinputdialog.h>

Collaboration diagram for QInputDialog:

Collaboration graph
[legend]
List of all members.

Static Public Member Functions

static QString getText (const QString &caption, const QString &label, const QString &text=QString::null, bool *ok=0, QWidget *parent=0, const char *name=0)
static QString getText (const QString &caption, const QString &label, QLineEdit::EchoMode echo, const QString &text=QString::null, bool *ok=0, QWidget *parent=0, const char *name=0)
static int getInteger (const QString &caption, const QString &label, int num=0, int from=-2147483647, int to=2147483647, int step=1, bool *ok=0, QWidget *parent=0, const char *name=0)
static double getDouble (const QString &caption, const QString &label, double num=0, double from=-2147483647, double to=2147483647, int decimals=1, bool *ok=0, QWidget *parent=0, const char *name=0)
static QString getItem (const QString &caption, const QString &label, const QStringList &list, int current=0, bool editable=TRUE, bool *ok=0, QWidget *parent=0, const char *name=0)

Private Types

enum  Type { LineEdit, SpinBox, ComboBox, EditableComboBox }

Private Slots

void textChanged (const QString &s)
void tryAccept ()

Private Member Functions

 QInputDialog (const QString &label, QWidget *parent=0, const char *name=0, bool modal=TRUE, Type type=LineEdit)
 ~QInputDialog ()
QLineEdit * lineEdit () const
QSpinBox * spinBox () const
QComboBox * comboBox () const
QComboBox * editableComboBox () const
void setType (Type t)
Type type () const

Private Attributes

QInputDialogPrivated

Friends

class QInputDialogPrivate

Detailed Description

A convenience dialog to get a simple input from the user.

The QInputDialog is a simple dialog which can be used if you need a simple input from the user. This can be text, a number or an item from a list. Also a label has to be set to tell the user what he/she should input.

In this Qt version only the 4 static convenience functions getText(), getInteger(), getDouble() and getItem() of QInputDialog are available.

Use it like this:

  bool ok = FALSE;
  QString text = QInputDialog::getText( tr( "Make an input" ), tr( "Please enter your name" ), QString::null, &ok, this );
  if ( ok && !text.isEmpty() )
      ;// user entered something and pressed ok
  else
      ;// user entered nothing or pressed cancel

There are more static convenience methods!

See also:
getText(), getInteger(), getDouble(), getItem()

Definition at line 52 of file qinputdialog.h.


Member Enumeration Documentation

enum QInputDialog::Type [private]
 

This enum type specifies the type of the dialog (which kind of input can be done):

  • LineEdit - A QLineEdit is used for taking the input, so a textual or (e.g. using a QValidator) a numerical input can be done. Using lineEdit() the QLineEdit can be accessed.
  • SpinBox - A QSpinBox is used for taking the input, so a decimal input can be done. Using spinBox() the QSpinBox can be accessed.
  • ComboBox - A read-only QComboBox is used for taking the input, so one item of a list can be chosen. Using comboBox() the QComboBox can be accessed.
  • EditableComboBox - An editable QComboBox is used for taking the input, so either one item of a list can be chosen or a text can be entered. Using editableComboBox() the QComboBox can be accessed.
Enumeration values:
LineEdit 
SpinBox 
ComboBox 
EditableComboBox 

Definition at line 60 of file qinputdialog.h.


Constructor & Destructor Documentation

QInputDialog::QInputDialog const QString label,
QWidget *  parent = 0,
const char *  name = 0,
bool  modal = TRUE,
Type  type = LineEdit
[private]
 

Constructs the dialog. label is the text which is shown to the user (it should mention to the user what he/she should input), parent the parent widget of the dialog, name the name of it and if you set modal to TRUE, the dialog pops up modally, else it pops up modeless. With type you specify the type of the dialog.

See also:
getText(), getInteger(), getDouble(), getItem()

Definition at line 121 of file qinputdialog.cpp.

References QInputDialogPrivate::comboBox, d, QInputDialogPrivate::editComboBox, FALSE, height, l, QInputDialogPrivate::lineEdit, QInputDialogPrivate::ok, qApp, setType(), QInputDialogPrivate::spinBox, QInputDialogPrivate::stack, textChanged(), tr, TRUE, tryAccept(), and width.

Referenced by getDouble(), getInteger(), getItem(), and getText().

QInputDialog::~QInputDialog  )  [private]
 

Destructor.

Definition at line 257 of file qinputdialog.cpp.

References d.


Member Function Documentation

QComboBox * QInputDialog::comboBox  )  const [private]
 

Returns the combobox, which is used in the ComboBox mode

Definition at line 200 of file qinputdialog.cpp.

References QInputDialogPrivate::comboBox, and d.

Referenced by getItem().

QComboBox * QInputDialog::editableComboBox  )  const [private]
 

Returns the combobox, which is used in the EditableComboBox mode

Definition at line 209 of file qinputdialog.cpp.

References d, and QInputDialogPrivate::editComboBox.

Referenced by getItem().

double QInputDialog::getDouble const QString caption,
const QString label,
double  num = 0,
double  from = -2147483647,
double  to = 2147483647,
int  decimals = 1,
bool *  ok = 0,
QWidget *  parent = 0,
const char *  name = 0
[static]
 

Static convenience function to get a decimal input from the user. caption is the text which is displayed in the title bar of the dialog. label is the text which is shown to the user (it should mention to the user what he/she should input), num the default decimal number which will be initially set to the line edit, from and to the range in which the entered number has to be, decimals the number of decimal which the number may have, ok a pointer to a bool which will be (if not 0!) set to TRUE if the user pressed ok or to FALSE if the user pressed cancel, parent the parent widget of the dialog and name the name of it. The dialogs pops up modally!

This method returns the number which has been entered by the user.

You will use this static method like this:

  bool ok = FALSE;
  double res = QInputDialog::getDouble( tr( "Please enter a decimal number" ), 33.7, 0, 1000, 2, &ok, this );
  if ( ok )
      ;// user entered something and pressed ok
  else
      ;// user pressed cancel

Definition at line 389 of file qinputdialog.cpp.

References lineEdit(), LineEdit, QString::number(), QInputDialog(), and TRUE.

int QInputDialog::getInteger const QString caption,
const QString label,
int  num = 0,
int  from = -2147483647,
int  to = 2147483647,
int  step = 1,
bool *  ok = 0,
QWidget *  parent = 0,
const char *  name = 0
[static]
 

Static convenience function to get an integral input from the user. caption is the text which is displayed in the title bar of the dialog. label is the text which is shown to the user (it should mention to the user what he/she should input), num the default number which will be initially set to the spinbox, from and to the range in which the entered number has to be, step the step in which the number can be increased/decreased by the spinbox, ok a pointer to a bool which will be (if not 0!) set to TRUE if the user pressed ok or to FALSE if the user pressed cancel, parent the parent widget of the dialog and name the name of it. The dialogs pops up modally!

This method returns the number which has been entered by the user.

You will use this static method like this:

  bool ok = FALSE;
  int res = QInputDialog::getInteger( tr( "Please enter a number" ), 22, 0, 1000, 2, &ok, this );
  if ( ok )
      ;// user entered something and pressed ok
  else
      ;// user pressed cancel

Definition at line 344 of file qinputdialog.cpp.

References FALSE, QInputDialog(), spinBox(), SpinBox, and TRUE.

QString QInputDialog::getItem const QString caption,
const QString label,
const QStringList list,
int  current = 0,
bool  editable = TRUE,
bool *  ok = 0,
QWidget *  parent = 0,
const char *  name = 0
[static]
 

Static convenience function to let the user select an item from a string list. caption is the text which is displayed in the title bar of the dialog. label is the text which is shown to the user (it should mention to the user what he/she should input), list the string list which is inserted into the combobox, current the number of the item which should be initially the current item, editable specifies if the combobox should be editable (if it is TRUE) or read-only (if editable is FALSE), ok a pointer to a bool which will be (if not 0!) set to TRUE if the user pressed ok or to FALSE if the user pressed cancel, parent the parent widget of the dialog and name the name of it. The dialogs pops up modally!

This method returns the text of the current item, or if editable was TRUE, the current text of the combobox.

You will use this static method like this:

  QStringList lst;
  lst << "First" << "Second" << "Third" << "Fourth" << "Fifth";
  bool ok = FALSE;
  QString res = QInputDialog::getItem( tr( "Please select an item" ), lst, 1, TRUE, &ok, this );
  if ( ok )
      ;// user selected an item and pressed ok
  else
      ;// user pressed cancel

Definition at line 437 of file qinputdialog.cpp.

References comboBox(), ComboBox, editableComboBox(), EditableComboBox, FALSE, QInputDialog(), and TRUE.

QString QInputDialog::getText const QString caption,
const QString label,
QLineEdit::EchoMode  mode,
const QString text = QString::null,
bool *  ok = 0,
QWidget *  parent = 0,
const char *  name = 0
[static]
 

Like above, but accepts an a mode which the line edit will use to display text.

See also:
getText()

Definition at line 297 of file qinputdialog.cpp.

References FALSE, lineEdit(), LineEdit, QInputDialog(), and TRUE.

QString QInputDialog::getText const QString caption,
const QString label,
const QString text = QString::null,
bool *  ok = 0,
QWidget *  parent = 0,
const char *  name = 0
[static]
 

Static convenience function to get a textual input from the user. caption is the text which is displayed in the title bar of the dialog. label is the text which is shown to the user (it should mention to the user what he/she should input), text the default text which will be initially set to the line edit, ok a pointer to a bool which will be (if not 0!) set to TRUE if the user pressed ok or to FALSE if the user pressed cancel, parent the parent widget of the dialog and name the name of it. The dialogs pops up modally!

This method returns the text which has been entered in the line edit.

You will use this static method like this:

  bool ok = FALSE;
  QString text = QInputDialog::getText( tr( "Please enter your name" ), QString::null, &ok, this );
  if ( ok && !text.isEmpty() )
      ;// user entered something and pressed ok
  else
      ;// user entered nothing or pressed cancel

Definition at line 285 of file qinputdialog.cpp.

References Dasher::Opts::Normal.

QLineEdit * QInputDialog::lineEdit  )  const [private]
 

Returns the line edit, which is used in the LineEdit mode

Definition at line 182 of file qinputdialog.cpp.

References d, and QInputDialogPrivate::lineEdit.

Referenced by getDouble(), and getText().

void QInputDialog::setType Type  t  )  [private]
 

Sets the input type of the dialog to t.

Definition at line 218 of file qinputdialog.cpp.

References QInputDialogPrivate::comboBox, ComboBox, d, EditableComboBox, QInputDialogPrivate::editComboBox, QInputDialogPrivate::lineEdit, LineEdit, QInputDialogPrivate::spinBox, SpinBox, QInputDialogPrivate::stack, and QInputDialogPrivate::type.

Referenced by QInputDialog().

QSpinBox * QInputDialog::spinBox  )  const [private]
 

Returns the spinbox, which is used in the SpinBox mode

Definition at line 191 of file qinputdialog.cpp.

References d, and QInputDialogPrivate::spinBox.

Referenced by getInteger().

void QInputDialog::textChanged const QString s  )  [private, slot]
 

For internal use only.

Definition at line 469 of file qinputdialog.cpp.

References d, QInputDialogPrivate::lineEdit, QInputDialogPrivate::ok, on, and str.

Referenced by QInputDialog().

void QInputDialog::tryAccept  )  [private, slot]
 

For internal use only.

Definition at line 487 of file qinputdialog.cpp.

References d, and QInputDialogPrivate::lineEdit.

Referenced by QInputDialog().

QInputDialog::Type QInputDialog::type  )  const [private]
 

Returns the input type of the dialog.

See also:
setType()

Definition at line 248 of file qinputdialog.cpp.

References d, and QInputDialogPrivate::type.


Friends And Related Function Documentation

friend class QInputDialogPrivate [friend]
 

Definition at line 97 of file qinputdialog.h.


Member Data Documentation

QInputDialogPrivate* QInputDialog::d [private]
 

Definition at line 95 of file qinputdialog.h.

Referenced by comboBox(), editableComboBox(), lineEdit(), QInputDialog(), setType(), spinBox(), textChanged(), tryAccept(), type(), and ~QInputDialog().


The documentation for this class was generated from the following files:
Generated on Sat Nov 5 17:47:33 2005 for OPIE by  doxygen 1.4.2