The contents of the Qt dialog are very difficult to remember, and often use the same operation, so you can use the various common dialog boxes to upload themselves. The following contains the Color dialog box, the open single (multiple) file dialog box, the Font dialog box, the Input dialog box, the Prompt Information dialog box, the Progress dialog box, the Qerrormessage dialog box, and the wizard dialog box.
Say less nonsense, directly on the code:
Color dialog box
Qcolor color = Qcolordialog::getcolor (qt::red,this,tr ("Color dialog box"));
Get the selected color and go to Settings
File dialog box
QString filename = qfiledialog::getopenfilename (this,tr ("File dialog box"), "F:", tr ("Picture file (*png)"));// If you want to get multiple files, use the Getopenfilenames method directly
Font dialog box
BOOL OK;
Qfont font = Qfontdialog::getfont (&ok,this);
Input dialog box
QString str = qinputdialog::gettext (THIS,TR ("Input String Dialog"), tr ("Please enter user name"), Qlineedit::normal,tr ("admin"), &ok);
if (OK)
Qdebug () << "Welcome";
int value = Qinputdialog::getint (this,tr ("Input Integer Dialog"), tr ("Please enter a value of 0-1000"), 100,0,1000,10,&ok);
if (OK)
Qdebug () << "Welcome";
Double value2 = qinputdialog::getdouble (this,tr ("Input floating Point Dialog"), tr ("Please enter a value of 0-1000"), 0.00,0,1000,2,&ok);
if (OK)
Qdebug () << "Welcome";
Qstringlist items;
ITEMS<<TR ("Entry 1") <<tr ("Entry 2");
QString item = Qinputdialog::getitem (THIS,TR ("Input Entry dialog box"), TR ("Please select an entry"), Items,0,true,&ok);
if (OK)
Qdebug () << "Welcome";
Prompt Information dialog box
int res = qmessagebox::question (this,tr ("Problem dialog box"), tr ("Nothing"), Qmessagebox::yes,qmessagebox::no);
if (res = = Qmessagebox::yes)//Problem dialog box
Qdebug () << "2333333";
int res1 = qmessagebox::information (THIS,TR ("Hint dialog box"), tr ("Nothing"), Qmessagebox::ok);
if (res = = Qmessagebox::ok)//Prompt dialog box
Qdebug () << "2333333";
int res3 = qmessagebox::warning (this,tr ("Warning dialog box"), tr ("Nothing"), Qmessagebox::abort);
if (res = = Qmessagebox::abort)
Qdebug () << "2333333"; //warning dialog box
int res4 = qmessagebox::critical (THIS,TR ("Critical error dialog box"), tr ("Nothing"), Qmessagebox::yesall);
if (res = = Qmessagebox::yesall)
Qdebug () << "2333333";
int res4 = Qmessagebox::about (This,tr ("About dialog box"), tr ("Nothing"), tr ("Like Life,like opensource"));
Progress dialog box
Qprogressdialog dialog (TR ("Progress"), tr ("Cancel"), 0,50000,this);
Dialog.setwindowtitle ("Progress dialog Box");
Dialog.setwindowmodality (Qt::windowmodal);
Dialog.show ();
for (int i = 0;i<=50000;i++) {
Dialog.setvalue (i);
Qcoreapplication::p rocessevents ();
if (dialog.wascanceled ())
Break
}
Used to eject the error message. Details, not just a hint. Different from the sub-methods within the Qmessagebox
Qerrormessage *dia = new Qerrormessage (this);
Dia->setwindowtitle ("Error");
Dia->showmessage (tr ("It ' t Error"));
Qwizardpage *createpage1 ();
Qwizardpage *createpage2 ();
Qwizardpage *createpage3 ();
Qwizardpage *mywidget::createpage1 ()///must note that this is a function based on the widget class, which does not exist in Qmainwindow
{
Qwizardpage *page = new Qwizardpage;
Page->settitle ("Introduction");
return page;
}
Qwizardpage *mywidget::createpage2 ()
{
Qwizardpage *page = new Qwizardpage;
Page->settitle ("User selection information");
return page;
}
Qwizardpage *mywidget::createpage3 ()
{
Qwizardpage *page = new Qwizardpage;
Page->settitle ("End");
return page;
}
Qwizard Wizard (this);
Wizard.setwindowtitle ("Wizard dialog Box");
Wizard.addpage (CreatePage1 ());
Wizard.addpage (CreatePage2 ());
Wizard.addpage (CreatePage3 ());
Wizard.exec ();
Hope to help you, and hope that we can spread the spirit of open source. Like Life,like opensource.
Continue learning Qt. There will be a lot of open source information.
The use and implementation of QT Common dialog box