Qt learning path (18): qinputdialog In the QT standard dialog box

Source: Internet
Author: User
This is the last part of the QT standard dialog box. As shown in its name, qinputdialog is used to receive user input. Qinputdialog provides some simple static functions to quickly create a dialog box, just as qcolordialog provides the getcolor function. First, let's take a look at the gettext function: Bool Isok;
Qstring text = qinputdialog: gettext (null, "Input dialog" ,
"Please input your comment" ,
Qlineedit: normal,
"Your comment" ,
& Isok );
If (Isok ){
Qmessagebox: Information (null, "Information" ,
"Your comment is: <B>" + TEXT + "</B>" ,
Qmessagebox: Yes | qmessagebox: No,
Qmessagebox: Yes );
} Code It is relatively simple. You can use the gettext function to pop up a dialog box for user input. The following shows the signature of this function: Static Qstring qinputdialog: gettext (qwidget * parent, Const Qstring & title, Const Qstring & label, qlineedit: echomode mode = qlineedit: normal, Const Qstring & text = qstring (), Bool * OK = 0, QT: windowflags flags = 0) the first parameter parent, that is, pointer to the familiar parent component. The second parameter title is the title of the dialog box; the third parameter label is the prompt Statement on the input box; the fourth parameter mode is used to specify the input mode of qlineedit. The value range is qlineedit: echomode. The default value is normal, that is, the password is displayed normally. You can also declare it as a password. For details, see the API. The fifth parameter text is the default string of qlineedit; the sixth parameter OK is optional. If it is not nll, the bool variable is set to true when you press the OK button in the dialog box, you can determine whether the user presses OK or cancel to determine whether the text is meaningful. The seventh parameter flags is used to specify the style of the dialog box. Although there are many parameters, the meaning of each parameter is obvious. You only need to refer to the API. The Return Value of the function is qstring, that is, the content entered by the user in qlineedit. As to whether the content is meaningful, it depends on whether the OK parameter is true. Qinputdialog not only provides functions for obtaining strings, but also getinteger, getdouble, and getitem functions.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.