Okay -- after some reading and coding, I cam up with the following:
#include<iostream>
#include<cstdio>
#include<fstream>
#include<string>
#include "bible2.h"
#include "ui_bible2.h"
using namespace std;
ui(new Ui::bible2)
{
ui->setupUi(this);
connect (ui->pushButton, SIGNAL(clicked()), this, SLOT(on_textEdit_textChanged()));
}
bible2::~bible2()
{
delete ui;
}
void bible2::on_pushButton_clicked()
{
ifstream in("example.csv");
if(not in)
{
perror("example.csv");
}
else
{
string text;
unsigned int numWords = 0;
unsigned int revnumWords = 0;
getline(in, text);
cout << "Text: \"" << text << "\"" << endl;
for(int i=0; i < text.size(); i++)
{
if(text[i] == ' ' || text[i] == '.' || text[i] == ',' ||
text[i] == '!' || text[i] == '?' || text[i] == ';')
{
++numWords;
//cout << numWords + 10 << " ";
if (numWords > 8)
{
cout << numWords + 12 << " ";
}
else
{
cout << numWords + 10 << " ";
}
}
}
in.close();
cout << "\n";
cout << "In this textual file \"example.csv\" there exists " << numWords;
cout << " words!"<< endl;
}
//return 0;
}
void bible2::on_textBrowser_historyChanged()
{
}
void bible2::on_textEdit_textChanged()
{
}
#include<iostream>
#include<cstdio>
#include<fstream>
#include<string>
#include "bible2.h"
#include "ui_bible2.h"
using namespace std;
bible2::bible2(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::bible2)
{
ui->setupUi(this);
connect (ui->pushButton, SIGNAL(clicked()), this, SLOT(on_textEdit_textChanged()));
}
bible2::~bible2()
{
delete ui;
}
void bible2::on_pushButton_clicked()
{
ifstream in("example.csv");
if(not in)
{
perror("example.csv");
}
else
{
string text;
unsigned int numWords = 0;
unsigned int revnumWords = 0;
getline(in, text);
cout << "Text: \"" << text << "\"" << endl;
for(int i=0; i < text.size(); i++)
{
if(text[i] == ' ' || text[i] == '.' || text[i] == ',' ||
text[i] == '!' || text[i] == '?' || text[i] == ';')
{
++numWords;
//cout << numWords + 10 << " ";
if (numWords > 8)
{
cout << numWords + 12 << " ";
}
else
{
cout << numWords + 10 << " ";
}
}
}
in.close();
cout << "\n";
cout << "In this textual file \"example.csv\" there exists " << numWords;
cout << " words!"<< endl;
}
//return 0;
}
void bible2::on_textBrowser_historyChanged()
{
}
void bible2::on_textEdit_textChanged()
{
void QTextEdit::append(const QString & text);
}
To copy to clipboard, switch view to plain text mode
I am STILL not getting the text to show up in the GUI window.
What is wrong with my append statement?
ironmantis7x
Bookmarks