Basti300
24th May 2010, 21:06
Hello,
Well im quiet new to QT Programming and im trying to create my own first programm at the moment. But i have some problems with finding the right functions for what i want to do.
Here is my Problem:
I want to open a file that has numbers in it. I want to read those number (4 coloumns and many rows) to some double-arrays so that i can then put them into a plot with QWT.
What i managed to do so far is make the QWT plot and open a QFileDialog that is connected to a QPushButton.
Now my first problem is that i cant get the filename of the file that i chose into a QString.
Then ive been trying to understand how to open a file and then read the data from it. There are so many things that i read about that im kinda confused now. Also i have no idea yet how i can test if the data is read correct. in normal C++ i simply used printf in a command prompt but with QT i dunno where i can print the numbers.
Well here is the code i wrote so far:
#include <QApplication>
#include <QFont>
#include <QPushButton>
#include <QWidget>
#include <qwt_plot.h>
#include <qwt_plot_curve.h>
#include <QFileDialog>
#include <QStringList>
#include <QLabel>
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
QWidget window;
window.resize(500, 500);
QFileDialog *dial = new QFileDialog( &window, "Test", TRUE);
dial->setFileMode(QFileDialog::ExistingFile);
QPushButton quit("Quit", &window);
quit.setFont(QFont("Times", 18, QFont::Bold));
quit.setGeometry(10, 450, 100, 40);
QObject::connect(&quit, SIGNAL(clicked()), &app, SLOT(quit()));
QPushButton open("Open", &window);
open.setFont(QFont("Times", 18, QFont::Bold));
open.setGeometry(150, 450, 100, 40);
QObject::connect(&open, SIGNAL(clicked()), dial, SLOT(exec()));
window.show();
return app.exec();
}
So i hope someone here can help me. If i missed something in my explanation let me know.
Thanks
Basti
Well im quiet new to QT Programming and im trying to create my own first programm at the moment. But i have some problems with finding the right functions for what i want to do.
Here is my Problem:
I want to open a file that has numbers in it. I want to read those number (4 coloumns and many rows) to some double-arrays so that i can then put them into a plot with QWT.
What i managed to do so far is make the QWT plot and open a QFileDialog that is connected to a QPushButton.
Now my first problem is that i cant get the filename of the file that i chose into a QString.
Then ive been trying to understand how to open a file and then read the data from it. There are so many things that i read about that im kinda confused now. Also i have no idea yet how i can test if the data is read correct. in normal C++ i simply used printf in a command prompt but with QT i dunno where i can print the numbers.
Well here is the code i wrote so far:
#include <QApplication>
#include <QFont>
#include <QPushButton>
#include <QWidget>
#include <qwt_plot.h>
#include <qwt_plot_curve.h>
#include <QFileDialog>
#include <QStringList>
#include <QLabel>
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
QWidget window;
window.resize(500, 500);
QFileDialog *dial = new QFileDialog( &window, "Test", TRUE);
dial->setFileMode(QFileDialog::ExistingFile);
QPushButton quit("Quit", &window);
quit.setFont(QFont("Times", 18, QFont::Bold));
quit.setGeometry(10, 450, 100, 40);
QObject::connect(&quit, SIGNAL(clicked()), &app, SLOT(quit()));
QPushButton open("Open", &window);
open.setFont(QFont("Times", 18, QFont::Bold));
open.setGeometry(150, 450, 100, 40);
QObject::connect(&open, SIGNAL(clicked()), dial, SLOT(exec()));
window.show();
return app.exec();
}
So i hope someone here can help me. If i missed something in my explanation let me know.
Thanks
Basti