Answer the question
In order to leave comments, you need to log in
How to work with texts in C++?
The bottom line: you need to take the file, read everything from it (done), by clicking on the button, get 2 lines from 2 input fields (also done), find its mention in the first line in the file and through " " count everything further to the endline, respectively, this compare with the second read line and print a message.
Below is what my brain managed to give birth to.
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <QFile>
#include <QString>
#include <QTextStream>
#include "iostream"
QString takeLog;
QString takePas;
QString aLine;
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
getTextFile();
on_pushButton_clicked();
}
MainWindow::~MainWindow()
{
delete ui;
}
void MainWindow::on_pushButton_clicked()
{
takeLog = ui->lineEdit->text();
takePas = ui->lineEdit_2->text();
if (aLine.contains(takeLog) == true)
{
int logLeng = takeLog.size();
int indexLog = aLine.lastIndexOf(takeLog) + logLeng;
}
else
{
printf("N");
}
}
void MainWindow::getTextFile(){
QFile accessFile("C:/Users/Kiaeru Sol'Nuem/Documents/FirstLoginWindow/FTAI.sp");
accessFile.open(QIODevice::ReadOnly);
QTextStream testStream(&accessFile);
aLine = testStream.readAll();
accessFile.close();
ui->textEdit->setPlainText(aLine);
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question