資源簡介
改例子是工作中從同事那里得到的參考例子,感覺經(jīng)典,就留下來了,雖然內容不多,幾乎涵蓋了所有相關的操作,很好的參考例子,所以要留下來,方便以后使用

代碼片段和文件信息
#include?“AddInfoForm.h“
#include?
#include?
#include?
#include?
#include?
#include?
#include?
#include?
#include?
#include?“DataStruct.h“
CAddInfoForm::CAddInfoForm(QWidget?*pWid)
????:QDialog(pWid)?m_pInfo(nullptr)?bChange(false)
{
????setupUI();
????m_pInfo?=?new?SPersonInfo;
}
CAddInfoForm::~CAddInfoForm()
{
}
SPersonInfo*?CAddInfoForm::getInfo()
{
????return?m_pInfo;
}
void?CAddInfoForm::changeMode()
{
????if?(m_pLEName->text().length()?>?0)
????{
????????if?(m_pLEPhone->text().length()?==?0?||?m_pLEPhone->text().length()?==?11)
????????{
????????????if?(m_pDEDate->date()?????????????{
????????????????m_pInfo->strName?=?m_pLEName->text();
????????????????m_pInfo->strAddr?=?m_pLEAddr->text();
????????????????//m_pInfo->eSex?=?Sex(m_pCBSex->currentIndex());
????????????????m_pInfo->bSex?=?m_pCBSex->currentIndex()?==?0???false?:?true;
????????????????m_pInfo->strBirth?=?m_pDEDate->date().toString(“yyyy-MM-dd“);
????????????????m_pInfo->strPhone?=?m_pLEPhone->text();
????????????????bChange?=?true;
????????????????this->close();
????????????????return;
????????????}
????????}
????}
????QMessageBox::warning(this?“Error“?QStringLiteral(“信息錄入錯誤“));
}
void?CAddInfoForm::setupUI()
{
????QLabel?*pLblName?=?new?QLabel(QStringLiteral(“姓名“));
????QLabel?*pLblSex?=?new?QLabel(QStringLiteral(“性別“));
????QLabel?*pLblAddr?=?new?QLabel(QStringLiteral(“住址“));
????QLabel?*pLblBirth?=?new?QLabel(QStringLiteral(“生日“));
????QLabel?*pLblPhone?=?new?QLabel(QStringLiteral(“電話“));
????pBtnAdd?=?new?QPushButton;
????pBtnCancel?=?new?QPushButton;
????pBtnAdd->setText(QStringLiteral(“確定“));
????pBtnCancel->setText(QStringLiteral(“取消“));
????connect(pBtnAdd?SIGNAL(clicked())?this?SLOT(changeMode()));
????connect(pBtnCancel?SIGNAL(clicked())?this?SLOT(close()));
????m_pLEName?=?new?QLineEdit;
????m_pCBSex?=?new?QComboBox;
????m_pLEAddr?=?new?QLineEdit;
????m_pDEDate?=?new?QDateEdit;
????m_pLEPhone?=?new?QLineEdit;
????m_pCBSex->addItem(QIcon(“..\\image\\group_manager.png“)?QStringLiteral(“男“));
????m_pCBSex->addItem(QIcon(“..\\image\\group_creator.png“)?QStringLiteral(“女“));
????QRegExp?regx(“^1(3[0-9]|4[57]|5[0-35-9]|7[0135678]|8[0-9])\\d{8}$“);
????QValidator?*validator?=?new?QRegExpValidator(regx?m_pLEPhone?);
????m_pLEPhone->setValidator(validator);
????m_pDEDate->setCalendarPopup(true);
????QHBoxLayout?*playoutName?=?new?QHBoxLayout;
????QHBoxLayout?*playoutSex?=?new?QHBoxLayout;
????QHBoxLayout?*playoutAddr?=?new?QHBoxLayout;
????QHBoxLayout?*playoutBirth?=?new?QHBoxLayout;
????QHBoxLayout?*playoutPhone?=?new?QHBoxLayout;
????QHBoxLayout?*playoutBtn?=?new?QHBoxLayout;
????QVBoxLayout?*pmainLayout?=?new?QVBoxLayout;
????playoutName->addWidget(pLblName);
????playoutName->addWidget(m_pLEName);
????playoutSex->addWidget(pLblSex
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件???????3884??2017-04-26?15:51??ModelViewText\AddInfoForm.cpp
?????文件????????613??2017-04-26?15:51??ModelViewText\AddInfoForm.h
?????文件???????6545??2017-04-26?15:51??ModelViewText\DataStruct.cpp
?????文件???????1741??2017-04-26?15:51??ModelViewText\DataStruct.h
?????文件????????193??2017-07-21?20:23??ModelViewText\main.cpp
?????文件????????138??2017-07-21?20:20??ModelViewText\mainwindow.cpp
?????文件????????227??2017-07-21?20:20??ModelViewText\mainwindow.h
?????文件????????487??2017-07-21?20:22??ModelViewText\ModelViewText.pro
?????文件??????18669??2017-07-21?20:22??ModelViewText\ModelViewText.pro.user
?????文件???????1973??2017-07-21?20:24??ModelViewText\tongxunbook.cpp
?????文件????????700??2017-04-26?15:51??ModelViewText\tongxunbook.h
?????目錄??????????0??2017-07-21?20:24??ModelViewText
-----------?---------??----------?-----??----
????????????????35170????????????????????12
評論
共有 條評論