代码拉取完成,页面将自动刷新
#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()));
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。