I've got a little qt interface designed to ask the user to input their Username and Password. Basically 2 input fields or lineEdit
s in Qt after which I verify them using a simple if statement.
My goal is that when these are verified, I would like my program to enter those in my batch file.
Is this an optimal approach for having user input interact with my batch? and more importantly, how do I go about it ?
Should I save the text from these "line edits" to strings and then input these strings in my .bat file?
Should I use ofstream
for that?
If that approach is good, how do I even go about it?
How can I save my lineEdit
text in strings?
I read a lot but I could barely find anything about saving lineEdit
s or lineEdit
s interacting with .bat
files.
Here is my mainwindow.cpp code:
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <QMessageBox>
#include <QCoreApplication>
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <algorithm>
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
}
MainWindow::~MainWindow()
{
delete ui;
}
void MainWindow::on_pushButton_clicked()
{
QString username = ui->lineEdit_username->text();
QString password = ui->lineEdit_password->text();
if (username == "test" && password == "test") {
QMessageBox::information(this,"Login", "Username Name and Password is correct"); }
else {
QMessageBox::warning(this,"Login","Username and password is incorrect"); }
}
I'm really sorry if my question is dumb, I just cant find anything and desperate, I'd really appreciate any contribution.