hi
i want to create a login page .
But this code does not work .
setPass.h
#ifndef SETPASS_H
#define SETPASS_H
#include <QDialog>
namespace Ui {
class setPass;
}
{
Q_OBJECT
public:
explicit setPass
(QWidget *parent
= 0);
~setPass();
bool setBool();
private slots:
void on_pushButton_clicked();
private:
Ui::setPass *ui;
bool res1 , res2 ;
};
#endif // SETPASS_H
#ifndef SETPASS_H
#define SETPASS_H
#include <QDialog>
namespace Ui {
class setPass;
}
class setPass : public QDialog
{
Q_OBJECT
public:
explicit setPass(QWidget *parent = 0);
~setPass();
void setPassword(QString &pass);
void setUsername(QString &user);
bool setBool();
private slots:
void on_pushButton_clicked();
private:
Ui::setPass *ui;
QString pass , user ;
bool res1 , res2 ;
};
#endif // SETPASS_H
To copy to clipboard, switch view to plain text mode
setPass.cpp
#include "setpass.h"
#include "ui_setpass.h"
setPass
::setPass(QWidget *parent
) : ui(new Ui::setPass)
{
ui->setupUi(this);
}
setPass::~setPass()
{
delete ui;
}
void setPass
::setPassword(QString &pass
) {
int a = c_pass.compare(pass);
if(a == 0)
res1 = true ;
}
void setPass
::setUsername(QString &user
) {
int a = c_user.compare(user);
if( a == 0 )
res2 = true ;
}
void setPass::on_pushButton_clicked()
{
setUsername(user = ui->userName->text());
setPassword( pass = ui->passWord->text());
}
bool setPass::setBool()
{
if(res2 == true && res1 == true)
return true ;
else return false ;
}
#include "setpass.h"
#include "ui_setpass.h"
setPass::setPass(QWidget *parent) :
QDialog(parent),
ui(new Ui::setPass)
{
ui->setupUi(this);
}
setPass::~setPass()
{
delete ui;
}
void setPass::setPassword(QString &pass)
{
QString c_pass = "123456";
int a = c_pass.compare(pass);
if(a == 0)
res1 = true ;
}
void setPass::setUsername(QString &user)
{
QString c_user = "m";
int a = c_user.compare(user);
if( a == 0 )
res2 = true ;
}
void setPass::on_pushButton_clicked()
{
setUsername(user = ui->userName->text());
setPassword( pass = ui->passWord->text());
}
bool setPass::setBool()
{
if(res2 == true && res1 == true)
return true ;
else return false ;
}
To copy to clipboard, switch view to plain text mode
main.cpp
#include "mainwindow.h"
#include <QApplication>
#include "dialog.h"
#include "setpass.h"
int main(int argc, char *argv[])
{
setPass pas ;
pas.show();
if(pas.setBool())
{
MainWindow w;
pas.close();
w.show();
}
return a.exec();
}
#include "mainwindow.h"
#include <QApplication>
#include "dialog.h"
#include "setpass.h"
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
setPass pas ;
pas.show();
if(pas.setBool())
{
MainWindow w;
pas.close();
w.show();
}
return a.exec();
}
To copy to clipboard, switch view to plain text mode
pic:
68799751914376939931.jpg
Bookmarks