Viadeo Twitter Google Bookmarks ! Facebook Digg del.icio.us MySpace Yahoo MyWeb Blinklist Netvouz Reddit Simpy StumbleUpon Bookmarks Windows Live Favorites 
Logo Documentation Qt ·  Page d'accueil  ·  Classes  ·  Annotées  ·  Hiérarchie  ·  Fonctions  ·  Structure  · 

QInputDialog Class Reference


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

#include <qinputdialog.h>

Inherits QDialog.

List of all member functions.

Static Public Members

  • QString getText ( const QString & caption, const QString & label, const QString & text = QString::null, bool * ok = 0, QWidget * parent = 0, const char * name = 0 ) 
  • 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 ) 
  • 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 ) 
  • 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 ) 
  • 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 ) 

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() and getItem().


Member Function Documentation

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

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

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

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().

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

Search the documentation, FAQ, qt-interest archive and more (uses www.trolltech.com):


This file is part of the Qt toolkit, copyright © 1995-2005 Trolltech, all rights reserved.

Cette page est une traduction d'une page de la documentation de Qt, écrite par Nokia Corporation and/or its subsidiary(-ies). Les éventuels problèmes résultant d'une mauvaise traduction ne sont pas imputables à Nokia. Qt 2.3
Copyright © 2012 Developpez LLC. Tous droits réservés Developpez LLC. Aucune reproduction, même partielle, ne peut être faite de ce site et de l'ensemble de son contenu : textes, documents et images sans l'autorisation expresse de Developpez LLC. Sinon, vous encourez selon la loi jusqu'à 3 ans de prison et jusqu'à 300 000 E de dommages et intérêts. Cette page est déposée à la SACD.
Vous avez déniché une erreur ? Un bug ? Une redirection cassée ? Ou tout autre problème, quel qu'il soit ? Ou bien vous désirez participer à ce projet de traduction ? N'hésitez pas à nous contacter ou par MP !
 
 
 
 
Partenaires

Hébergement Web