C + + QT Programming Practice--Consignee information list

Source: Internet
Author: User

Consignee Information list (improved):

Dialog.h file:

#ifndef  DIALOG_H#define DIALOG_H#include <QDialog> #include  <QLineEdit> #include  <QLabel> #include  <QPushButton> #include  <qcombobox>class dialog :  public qdialog{    q_objectpublic:    dialog (QWidget * parent = 0);     ~dialog ();signals:private slots:     Void cleareditline ();     void saveclicked ();p rivate:     qlabel *name;    qlabel *area;    qlabel *address;     QLabel *phone;    QLabel *huo;     Qlabel *tel;    qlabel *email;    qlabel *addressaliase ;    qlabel *note;    qlineedit *editname;     qcombobox *cobprovince;    qcombobox *cobcity;    qcombobox *cobarea;     QLineEdit *editAddress;    QLineEdit *editPhone;     QLineEdit *editTel;    QLineEdit *editEmail;     qlineedit *editaddressaliase;    qpushbutton *save;}; #endif  // dialog_h

Dialog.cpp File:

#include   "dialog.h" #include  <QtGui> #include  <qlayout>dialog::D ialog (qwidget * Parent)     : qdialog (parent) {    name = new qlabel (TR ("Consignee:"));    editname = new qlineedit;    name-> SetBuddy (Editname),     area = new qlabel (tr ("area:");     cobprovince = new qcombobox ();     cobprovince->additem (TR ("Please select"));     cobprovince->additem (tr ("Shaanxi"));     cobcity = new  qcombobox ();     cobcity->additem (TR ("Please select"));    cobcity-> AddItem (tr ("Xian City"));     cobarea = new qcombobox ();     Cobarea->additem (TR ("Please select"))     cobarea->additem (tr ("Weiyang District"));     Cobarea->additem (tr("Changan District"));     cobarea->additem (tr ("Beilin District"));     cobarea->additem (tr ("New Town"));     cobarea->additem (TR ("High-tech Zone"));     cobarea->additem (tr ("Lianhu District"));     cobarea->additem (tr ("Yanta District"));     cobarea->additem (tr ("Lintong"));     address = new qlabel (TR ("Detailed Address:"));     editaddress  = new qlineedit;    address->setbuddy (editAddress);     phone = new qlabel (TR ("Mobile phone Number:"));    editphone = new  Qlineedit;    phone->setbuddy (editphone);     huo = new  qlabel (TR ("or")),     tel = new qlabel (tr ("fixed phone:"));     edittel = new qlineedit;    tel->setbuddy (EditTel);     emAil = new qlabel (TR ("mailbox:"));    editemail = new qlineedit;     email->setbuddy (editemail);     addressaliase = new  qlabel (TR ("Address alias:"));    editaddressaliase = new qlineedit;     addressaliase->setbuddy (editaddressaliase);     note = new  qlabel ("Set an easy-to-remember name, such as" Send To Home "," Send to the Company "),     save = new qpushbutton (tr ("Save delivery Address");     connect (Save, signal (clicked ()),  this, slot (saveclicked ()));     QHBoxLayout *areaLayout = new QHBoxLayout;     Arealayout->addwidget (cobprovince);     arealayout->addwidget (cobCity);     arealayout->addwidget (Cobarea);    qvboxlayout *leftphone =  New qvboxlayout;&nBsp;   leftphone->addwidget (phone);     leftphone->addwidget (EditPhone );     //leftphone->addstretch ();     qvboxlayout *righttel  = new qvboxlayout;    righttel->addwidget (tel);     Righttel->addwidget (Edittel);     //righttel->addstretch ();     Qhboxlayout *numlayout = new qhboxlayout;    numlayout->addlayout ( Leftphone);     numlayout->addwidget (Huo);    numlayout-> Addlayout (Righttel);     //numlayout->addstretch ();     qhboxlayout  *aliaselayout = new qhboxlayout;    aliaselayout->addwidget ( Editaddressaliase);     aliaselayout->addwidget (note);     // Aliaselayout->addstretch ();    QVBoxLayout *leftMainLayout = new QVBoxLayout;     Leftmainlayout->addwidget (name);     leftmainlayout->addwidget (EDITNAME,&NBSP;10);     leftmainlayout->addwidget (area);    //     Leftmainlayout->addlayout (arealayout);     leftmainlayout->addwidget (address);     leftmainlayout->addwidget (editaddress);    leftmainlayout-> Addlayout (numlayout);     leftmainlayout->addwidget (email);     Leftmainlayout->addwidget (Editemail);     leftmainlayout->addwidget (addressAliase);     leftmainlayout->addlayout (aliaselayout);    leftmainlayout-> AddWidget (save, 20);     //leftmainlayout->addstretch ();     qvboxlayout *rightmainlayout = new QVBoxLayout;    QHBoxLayout *mainLayout = new  Qhboxlayout;    mainlayout->addlayout (leftmainlayout);     Mainlayout->addlayout (rightmainlayout, 10);     setlayout (mainLayout);     setwindowtitle (TR ("Add delivery Address")),     setfixedheight (Sizehint (). Height ());     setfixedwidth (Sizehint (). width ()); Dialog::~dialog () {}void dialog::cleareditline () {    editname->settext ("");     //cobprovince->setitemtext (1);     editaddress->settext ("");     editphone->settext ("");     edittel->settext ("");     editemail->settext ("");     editaddressaliase->settext ("");} Void dialog::saveclicked () {    qdialog *showdialog = new qdialog; &Nbsp;   qstring textname = editname->text ();     qstring  textprovince = cobprovince->currenttext ();     qstring textcity  = cobcity->currenttext ();    qstring textarea = cobarea-> Currenttext ();     qstring textaddress = editaddress->text ();     qstring textphone = editphone->text ();    qstring  Texttel = edittel->text ();     qstring textemail = editemail- >text ();     qstring textaddressaliase = editaddressaliase->text ();     qlabel *showname = new qlabel (Name->text ()  + textName );     qlabel *showarea = new qlabel (Area->text ()  +  Textprovince + textcity + textarea);     qlabel *showaddress = new qlabel (address- >text ()  + textaddress);     qlabel *showphone = new qlabel (Phone->text ()  + textphone);    qlabel *showtel = new  Qlabel (Tel->text ()  + texttel);     qlabel *showemail = new  qlabel (Email->text ()  + textemail);     qlabel *showaddressaliase  = new qlabel (Addressaliase->text ()  + textaddressaliase);     Qpushbutton *edittext = new qpushbutton (tr ("edit"));     qpushbutton  *deletetext = new qpushbutton (tr ("delete"));     showdialog->connect ( Edittext, signal (clicked ()),  showdialog, slot (Close ()));    showdialog-> Connect (deletetext, signal(Clicked ()),  showdialog, slot (Close ()));     showdialog->connect (DeleteText,  signal (clicked ()),  this, slot (Cleareditline ()));     qhboxlayout * Buttonlayout = new qhboxlayout;    buttonlayout->addwidget (EditText);     buttonlayout->addwidget (deletetext);     qvboxlayout * Mainlayout = new qvboxlayout;    mainlayout->addlayout (buttonLayout);     mainlayout->addwidget (ShowName);     mainlayout->addwidget ( Showarea);     mainlayout->addwidget (showaddress);     mainlayout- >addwidget (Showphone);     mainlayout->addwidget (Showtel);     Mainlayout->addwidget (Showemail);     mainlayout->addwidget (showAddressAliase);     showdialog->seTlayout (mainlayout);     showdialog->setwindowtitle (Textname + textarea);     showdialog->exec ();}

Main.cpp file:

#include "dialog.h" #include <qapplication>int main (int argc, char *argv[]) {qapplication A (argc, argv);    Dialog W;    W.show (); return a.exec ();}

Run:

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/5B/E7/wKiom1UVSsSDGqttAAEjeeFa5NE608.jpg "title=" Consignee list " alt= "Wkiom1uvsssdgqttaaejeefa5ne608.jpg"/>

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/5B/E1/wKioL1UVTGugdvMlAACRAg3AWVY611.jpg "title=" consignee List 2 "alt=" Wkiol1uvtgugdvmlaacrag3awvy611.jpg "/>


This article is from the "V-Face" blog, be sure to keep this source http://xuzhen1024.blog.51cto.com/8881317/1625810

C + + QT Programming Practice--Consignee information list

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.