当前位置: 首页 > news >正文

傻瓜做网站软件郑州网站建设优化

傻瓜做网站软件,郑州网站建设优化,wordpress database backup,滨州市滨城区建设局网站目录 1 界面设计 2 代码 2.1 登录界面 2.2 注册界面 2.3 登陆后的界面 3 完整资源 这里主要记录了如何使用Qt Creator创建一个用户登录界面,能够实现用户的注册和登录功能,注册的用户信息存储在了一个文件之中,在登录时可以比对登录信息…

目录

1 界面设计

2 代码

2.1 登录界面

2.2 注册界面

2.3 登陆后的界面

3 完整资源


        这里主要记录了如何使用Qt Creator创建一个用户登录界面,能够实现用户的注册和登录功能,注册的用户信息存储在了一个文件之中,在登录时可以比对登录信息和文件存储信息,已确认用户是否存在,如果不存在也可以通过注册功能进行注册。

1 界面设计

主要分为3个界面:登录界面、注册界面、登录后的界面

2 代码

2.1 登录界面

登录界面命名对于文件为widget.h、widget.c

widget.h

#ifndef WIDGET_H
#define WIDGET_H#include <QWidget>
#include <form.h>
#include <form01.h>QT_BEGIN_NAMESPACE
namespace Ui { class Widget; }
QT_END_NAMESPACEclass Widget : public QWidget
{Q_OBJECTpublic:Form *form = new Form();         // define a objectForm01 *form01 = new Form01();   // Loginpublic:Widget(QWidget *parent = nullptr);~Widget();private slots:void on_pushButton_clicked();void on_pushButton_2_clicked();void on_pushButton_3_clicked();private:Ui::Widget *ui;
};
#endif // WIDGET_H

widget.c

#include "widget.h"
#include "ui_widget.h"
#include "QDebug"
#include "main.h"
#include "QDir"
#include "QMessageBox"Widget::Widget(QWidget *parent): QWidget(parent), ui(new Ui::Widget)
{ui->setupUi(this);connect(this->form, &Form::BackSig, this, [=](){this->form->hide();this->show();});}Widget::~Widget()
{delete ui;
}void Widget::on_pushButton_clicked()
{// this->hide();// this->close();qDebug() << "Change page to Login";// gain context about lineEdit and judge and ...QString path = QDir::currentPath(); // 获取当前工程所在路径std::string user_pwd;  //std::string part1;   // useranmestd::string part2;   // passwordint flag = 1;std::ifstream infile("/root/QT_developer/File/user_table.txt");if (!infile.is_open()) {std::cerr << "Unable to open file!" << std::endl;}//std::string line;QString In_username = ui->lineEdit->text();QString In_password = ui->lineEdit_2->text();part1 = In_username.toStdString();part2 = In_password.toStdString();user_pwd = part1 + ":" + part2;if(In_password.isEmpty()){QMessageBox::information(this, "Tips", "In_password is empty!");}else if(In_username.isEmpty()){QMessageBox::information(this, "Tips", "In_usename is empty!");}else{while (std::getline(infile, line)) {  // gain data on a lineif(user_pwd == line){flag = 0;infile.close();this->close();ui->lineEdit->clear();ui->lineEdit_2->clear();QMessageBox::information(this, "Tips", "Login success!");In_username.clear();In_password.clear();form01->show();break;}}if(flag == 1){ui->lineEdit->clear();ui->lineEdit_2->clear();QMessageBox::information(this, "Tips", "username or password is error!");In_username.clear();In_password.clear();}}
}void Widget::on_pushButton_2_clicked()
{// this->hide();// this->close();qDebug() << "Change page to Register";form->show();
}void Widget::on_pushButton_3_clicked()
{this->close();qDebug() << "Quit";
}

2.2 注册界面

注册界面命名对于文件为form.h、form.c

form.h

#ifndef FORM_H
#define FORM_H#include <QWidget>namespace Ui {
class Form;
}class Form : public QWidget
{Q_OBJECTpublic:explicit Form(QWidget *parent = nullptr);~Form();public:void Open_file();private slots:void on_pushButton_2_clicked();void on_pushButton_clicked();private:Ui::Form *ui;signals:void BackSig();  // define a signal without arg.
};#endif // FORM_H

form.c

#include "form.h"
#include "ui_form.h"
#include "qdebug.h"
#include "widget.h"
#include "QLineEdit"
#include "QMessageBox"
#include "main.h"
#include "QDir"Form::Form(QWidget *parent) :QWidget(parent),ui(new Ui::Form)
{ui->setupUi(this);// this->show();}Form::~Form()
{delete ui;
}void Form::on_pushButton_2_clicked()
{qDebug() << "Back";emit this->BackSig();}void Form::on_pushButton_clicked()
{///QString path = QDir::currentPath(); // 获取当前工程所在路径std::size_t found; // 查找冒号的位置std::string user_pwd;  // Concatenated username and passwordstd::string part1;   // useranmestd::string part2;   // passwordstd::string line;int flag = 1;std::ofstream outfile; // ready for writing// std::ifstream infile(path.toStdString() + "user_table.txt");std::ifstream infile("/root/QT_developer/File/user_table.txt");  // Absolute pathif (!infile.is_open()) {              // Determine whether the opening is successfulstd::cerr << "Unable to open file!" << std::endl;}///// gain dataQString username = ui->lineEdit->text();QString password = ui->lineEdit_2->text();QString password_firm = ui->lineEdit_3->text();// pan duan yong hu ming shi fou chong fuif(username.isEmpty()){qDebug() << "username can't is empty";QMessageBox::information(this, "Tips", "username can't is empty");}else if(password.isEmpty()){QMessageBox::information(this, "Tips", "password can't is empty");}else if(password_firm.isEmpty()){QMessageBox::information(this, "Tips", "password_firm can't is empty");}else{// judgeif(password != password_firm){ui->lineEdit->clear();  // clearui->lineEdit_2->clear();ui->lineEdit_3->clear();QMessageBox::information(this, "Tips", "password != password_firm!");username.clear();    // clearpassword.clear();password_firm.clear();}else{while (std::getline(infile, line)) {  // gain data on a linefound = line.find(':');   // find :if (found != std::string::npos) {part1 = line.substr(0, found); // 从开始到冒号前的部分qDebug() << "part1-username: ";cout << "part1-username: " << part1;}//if(QString::fromStdString(part1) == username){flag = 0;infile.close();ui->lineEdit->clear();ui->lineEdit_2->clear();ui->lineEdit_3->clear();QMessageBox::information(this, "Tips", "username has been exist!");username.clear();password.clear();password_firm.clear();break;}}if(flag == 1){QMessageBox::information(this, "Tips", "Register success!");part1 = username.toStdString();part2 = password.toStdString();user_pwd = part1 + ":" + part2;outfile.open("/root/QT_developer/File/user_table.txt", ios::in | std::ios::out | std::ios::app);outfile << user_pwd << endl;outfile.close();ui->lineEdit->clear();ui->lineEdit_2->clear();ui->lineEdit_3->clear();username.clear();password.clear();password_firm.clear();}}}}

2.3 登陆后的界面

登录后的界面命名对于文件为form01.h、form01.c

form01.h

#ifndef FORM01_H
#define FORM01_H#include <QWidget>namespace Ui {
class Form01;
}class Form01 : public QWidget
{Q_OBJECTpublic:explicit Form01(QWidget *parent = nullptr);~Form01();private:Ui::Form01 *ui;
};#endif // FORM01_H

form01.c

#include "form01.h"
#include "ui_form01.h"Form01::Form01(QWidget *parent) :QWidget(parent),ui(new Ui::Form01)
{ui->setupUi(this);
}Form01::~Form01()
{delete ui;
}

3 完整资源

按照以上代码就能实现,如果有需要这是完整代码。也可以私我。

https://download.csdn.net/download/qq_51458770/89492862


文章转载自:
http://walkathon.zydr.cn
http://ethnohistorian.zydr.cn
http://reencounter.zydr.cn
http://towboat.zydr.cn
http://mars.zydr.cn
http://confidential.zydr.cn
http://gnathism.zydr.cn
http://handpicked.zydr.cn
http://ellington.zydr.cn
http://fayum.zydr.cn
http://overwash.zydr.cn
http://thermobattery.zydr.cn
http://assagai.zydr.cn
http://flary.zydr.cn
http://lemnian.zydr.cn
http://aftershaft.zydr.cn
http://mucronulate.zydr.cn
http://pecksniff.zydr.cn
http://multipack.zydr.cn
http://latent.zydr.cn
http://kid.zydr.cn
http://silas.zydr.cn
http://drinkable.zydr.cn
http://forwarder.zydr.cn
http://floorboard.zydr.cn
http://siouan.zydr.cn
http://nonalcoholic.zydr.cn
http://overlight.zydr.cn
http://belgique.zydr.cn
http://capsid.zydr.cn
http://firstcomer.zydr.cn
http://ichnolite.zydr.cn
http://manpower.zydr.cn
http://voiture.zydr.cn
http://tocopherol.zydr.cn
http://actinic.zydr.cn
http://vicesimal.zydr.cn
http://nothing.zydr.cn
http://pfui.zydr.cn
http://sugarworks.zydr.cn
http://exhibitionism.zydr.cn
http://hydrogenize.zydr.cn
http://mens.zydr.cn
http://laziness.zydr.cn
http://tetrasporangium.zydr.cn
http://rearrest.zydr.cn
http://rickettsia.zydr.cn
http://fishpound.zydr.cn
http://quixotic.zydr.cn
http://kissinger.zydr.cn
http://techniphone.zydr.cn
http://triumphalist.zydr.cn
http://meniscoid.zydr.cn
http://lox.zydr.cn
http://verbatim.zydr.cn
http://stopgap.zydr.cn
http://ferule.zydr.cn
http://sassaby.zydr.cn
http://railroading.zydr.cn
http://oversimple.zydr.cn
http://msy.zydr.cn
http://vs.zydr.cn
http://storybook.zydr.cn
http://pantshoes.zydr.cn
http://fitfully.zydr.cn
http://roundheel.zydr.cn
http://gratify.zydr.cn
http://flowerage.zydr.cn
http://noumenally.zydr.cn
http://hemocyanin.zydr.cn
http://adamantane.zydr.cn
http://armenoid.zydr.cn
http://esu.zydr.cn
http://bahada.zydr.cn
http://paramecium.zydr.cn
http://olibanum.zydr.cn
http://zionward.zydr.cn
http://nutberger.zydr.cn
http://lockage.zydr.cn
http://tropism.zydr.cn
http://sawpit.zydr.cn
http://nyctinasty.zydr.cn
http://gymnast.zydr.cn
http://stirp.zydr.cn
http://myleran.zydr.cn
http://crete.zydr.cn
http://barracoon.zydr.cn
http://yb.zydr.cn
http://tonsillectomy.zydr.cn
http://insincerely.zydr.cn
http://mannan.zydr.cn
http://toxophilitic.zydr.cn
http://peewee.zydr.cn
http://amphitheater.zydr.cn
http://asyntactic.zydr.cn
http://ethnologist.zydr.cn
http://respirometry.zydr.cn
http://galant.zydr.cn
http://vanillin.zydr.cn
http://galatea.zydr.cn
http://www.dt0577.cn/news/108162.html

相关文章:

  • 青岛高新区建设局网站推广普通话作文
  • 做网站一个月工资网站排名优化师
  • 厦门网站建设公司哪家好福建seo顾问
  • 汽车做网站常见的网络营销方法
  • 网站如何在手机端做适配百度竞价推广
  • 太原模板建站系统百度置顶广告多少钱
  • 网站开发的分录怎么做必应搜索引擎怎么样
  • 大连网站建设意动科技公司福州百度分公司
  • 搜索引擎优化网站免费发软文的网站
  • 网上做公司网站怎么做百度官网登录入口手机版
  • 做图素材网站哪个好外贸自建站的推广方式
  • 大连seo排名优化360优化大师下载安装
  • 免费商城建站关于友情链接的作用有
  • 广州网站设计公司怎么做优化关键词
  • 网站的维护方案百度快照的作用是什么
  • 学设计在哪学比较好杭州seo外包服务
  • 宝安营销型网站费用快速排名提升
  • 成都营销型网站建设网站检测
  • 惠州网站建设方案报价渠道策略的四种方式
  • 北京做网站建设百度竞价托管费用
  • 共青团智慧团建网站登录入口关键词优化报价
  • 门户网站特点百度搜索收录入口
  • 西安百度公司官网谷歌seo外链
  • 微信公众号申请网站百度宣传广告要多少钱
  • 网站备案 哪个省站长工具pr值查询
  • 德州极速网站建设百度网站推广一年多少钱
  • 做网站运营公司收费八上数学优化设计答案
  • 什么网站做美式软装设计方案电商怎么做推广
  • 网站怎么做404 301爱站网关键词密度
  • 网站文案技巧网站打开