could anyone give a helping hand?
my code was able to read the textfile and display using gui.
the textfile "data.txt" is in this form
123-GCF 2 1 2
124-BOG 4 1 2 5 7
456-DES 6 6 7 8 9 3 1
234-REE 2 9 8
wherein :
123-GCF = code
2 = size of array
1 2 = array of numbers
i need to count the frequency of numbers in the third column that is the array of numbers
and display the result in the gui.
in this example once i clicked the display button it should show
1 = 3;
2 = 2;
3 = 1;
...
...
...
so far I have this code................... your help is very much appreciated..
thanks in advance ....
#include<QtCore>
#include<QLabel>
#include<QFile>
#include<QtGui>
#include<QString>
#include <iostream>
class DblVec : public QVector<int>{
public:
DblVec(int n):QVector<int>(n){}
};
using namespace std;
int main(int argc, char *argv[])
{
quint32 size;
DblVec line(size);
QFile infile
("data.txt");
window->setWindowTitle("Data");
readFile->setText("Display Relative Frequency");
layout->addWidget(readFile, 0, 1);
if ( infile.
open(QIODevice::ReadOnly |QIODevice
::Text) ) while(!stream.atEnd())
{
line2 = stream.readAll();
}
browse->setText(line2);
browse->setVerticalScrollBar(scrollbar);
browse->show();
infile.close();
}
layout->addWidget(browse, 0, 0);
window->setLayout(layout);
window->resize(500, 400);
window->show();
return a.exec();
}
#include<QtCore>
#include<QLabel>
#include<QFile>
#include<QtGui>
#include<QString>
#include <iostream>
class DblVec : public QVector<int>{
public:
DblVec(int n):QVector<int>(n){}
};
using namespace std;
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
QWidget *window = new QWidget;
QGridLayout *layout = new QGridLayout;
QPushButton *readFile = new QPushButton;
QString date;
quint32 size;
DblVec line(size);
QTextBrowser *browse = new QTextBrowser;
QScrollBar *scrollbar = new QScrollBar;
QFile infile("data.txt");
window->setWindowTitle("Data");
readFile->setText("Display Relative Frequency");
layout->addWidget(readFile, 0, 1);
if ( infile.open(QIODevice::ReadOnly |QIODevice::Text) )
{QString line2;
QTextStream stream( &infile );
while(!stream.atEnd())
{
line2 = stream.readAll();
}
browse->setText(line2);
browse->setVerticalScrollBar(scrollbar);
browse->show();
infile.close();
}
layout->addWidget(browse, 0, 0);
window->setLayout(layout);
window->resize(500, 400);
window->show();
return a.exec();
}
To copy to clipboard, switch view to plain text mode
Bookmarks