1 Star 0 Fork 1

Ammon888/Qt_StudentManager_Project

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
SmallWidget.cpp 2.75 KB
一键复制 编辑 原始数据 按行查看 历史
#include "SmallWidget.h"
SmallWidget::SmallWidget(QWidget *parent)
: QWidget{parent}
{
setWindowTitle("学生管理");
setWindowFlags(Qt::Window | Qt::WindowCloseButtonHint);
resize(320, 400);
setMaximumWidth(320);
setMinimumHeight(320);
SmallInit();
}
void SmallWidget::SaveClick()
{
qDebug() << "Save";
}
void SmallWidget::ExitClick()
{
qDebug() << "Exit";
this->hide();
}
void SmallWidget::SmallInit()
{
int x_init_pos = 50, y_init_pos = 50;
int x_pos = 0, y_pos = 0;
QLabel *label1 = new QLabel("学号:", this);
label1->move(x_init_pos, y_init_pos);
QLineEdit *snoLineEdit = new QLineEdit(this);
x_pos = x_init_pos + 50;
y_pos = y_init_pos - 5;
snoLineEdit->move(x_pos, y_pos);
label1->setBuddy(snoLineEdit);
//只能输入数字
snoLineEdit->setValidator(new QRegExpValidator(QRegExp("[0-9]+$")));
QLabel *label2 = new QLabel("学生姓名:", this);
QLineEdit *snameLineEdit = new QLineEdit(this);
label2->move(x_init_pos - 30, y_init_pos + 50);
x_pos = x_init_pos + 50;
y_pos = label2->y() - 5;
snameLineEdit->move(x_pos, y_pos);
label2->setBuddy(snameLineEdit);
QLabel *label6 = new QLabel("性别:", this);
QRadioButton *sboyRadioBt= new QRadioButton("男", this);
QRadioButton *sgirlRadioBt = new QRadioButton("女", this);
label6->move(x_init_pos, y_init_pos + 100);
x_pos = x_init_pos + 60;
y_pos =label6->y();
sboyRadioBt->move(x_pos, y_pos);
sgirlRadioBt->move(x_pos + 100, y_pos);
sboyRadioBt->setChecked(true);
QLabel *label3 = new QLabel("出生日期:", this);
QLineEdit *sbirthLineEdit = new QLineEdit(this);
label3->move(x_init_pos - 30, y_init_pos + 150);
x_pos = x_init_pos + 50;
y_pos = label3->y() - 5;
sbirthLineEdit->move(x_pos, y_pos);
label3->setBuddy(sbirthLineEdit);
QLabel *label4 = new QLabel("qq:", this);
QLineEdit *sqqLineEdit = new QLineEdit(this);
label4->move(x_init_pos + 15, y_init_pos + 200);
x_pos = x_init_pos + 50;
y_pos = label4->y() - 5;
sqqLineEdit->move(x_pos, y_pos);
label4->setBuddy(sqqLineEdit);
QLabel *label5 = new QLabel("电话:", this);
QLineEdit *sphoneLineEdit = new QLineEdit(this);
label5->move(x_init_pos, y_init_pos + 250);
x_pos = x_init_pos + 50;
y_pos = label5->y() - 5;
sphoneLineEdit->move(x_pos, y_pos);
label5->setBuddy(sphoneLineEdit);
QPushButton *saveBt = new QPushButton("保存", this);
QPushButton *exitBt = new QPushButton("取消", this);
saveBt->move(this->width()-200, this->height()-40);
exitBt->move(this->width()-100, this->height()-40);
connect(saveBt, SIGNAL(clicked()), this, SLOT(SaveClick()));
connect(exitBt, SIGNAL(clicked()), this, SLOT(ExitClick()));
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
C/C++
1
https://gitee.com/Ammon888/Qt_StudentManager_Project.git
git@gitee.com:Ammon888/Qt_StudentManager_Project.git
Ammon888
Qt_StudentManager_Project
Qt_StudentManager_Project
master

搜索帮助