#include "sistema.h" #include "ui_sistema.h" #include #include "QMessageBox" #include "criptosistemas.h" Sistema::Sistema(QWidget *parent) : QMainWindow(parent), ui(new Ui::Sistema) { ui->setupUi(this); setWindowTitle("**** Criptosistema ****"); setWindowFlags(Qt::Window|Qt::MSWindowsFixedSizeDialogHint|Qt::WindowMinimizeButtonHint); //this->ui->pass->placeholderText(); connect(ui->pushButton_2,SIGNAL(clicked()),this,SLOT(Autenticate())); } Sistema::~Sistema() { delete ui; } void Sistema::Autenticate() { QString user = ui->user->text(); QString pass = ui->pass->text(); qDebug() << user; qDebug() << pass; //bool ok = user == "admin" && pass == "123" ? true: false; if (user == ""){ QString style = "QLabel{ color: #DF0101; font-size: 11px; font-style: italic; margin-left: 10px; }"; this->ui->label_6->setText("Este campo es obigatorio"); ui->label_6->setStyleSheet(style); if (pass != "") { this->ui->label_7->setText(""); QString stylee = "QLabel{ background-color: #fffff; }"; this->ui->label_8->setText(""); ui->label_8->setStyleSheet(stylee); } } if (pass == ""){ QString style = "QLabel{ color: #DF0101; font-size: 11px; font-style: italic; margin-left: 10px; }"; this->ui->label_7->setText("Este campo es obigatorio"); ui->label_7->setStyleSheet(style); if (user != "") { this->ui->label_6->setText(""); QString stylee = "QLabel{ background-color: #fffff; }"; this->ui->label_8->setText(""); ui->label_8->setStyleSheet(stylee); } } if (user != "" && pass != ""){ if (user == "admin" && pass == "123"){ CriptoSistemas *app = new CriptoSistemas; app->show(); close(); } else{ QString style = "QLabel{ background-color: #FCDFDF; font-size: 13px; font-style: italic; margin-left: 10px; }"; this->ui->label_8->setText("El usuario no es vĂ¡lido"); this->ui->label_7->setText(""); this->ui->label_6->setText(""); ui->label_8->setStyleSheet(style); } } }