thanks a lot for your help
but when i use this code i have some errors
i am using GUI application
can you help me to fix this?. sorry for annoying you but i am a beginner ... thanks in advance
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include<QFile>
#include<QtCore>
#include<QtGui>
#include<QTextStream>
MainWindow
::MainWindow(QWidget *parent
) : ui(new Ui::MainWindow)
{
ui->setupUi(this);
ui->label->setText("Hello User :)");
}
MainWindow::~MainWindow()
{
delete ui;
}
void MainWindow::on_pushButton_clicked()
{
QFile file("C:/ahmad/ecg test/tst.txt");
{
ui->label->setText(" OOP : File Cant be Opened");
return;
}
ui->label->setText("DONE : file opened");
while (!in.atEnd())
{
list << in.readLine();
}
file.close();
data = new double[list.size()];
for(int i = 0; i< list.size(); i++)
{
data[i] = list[i].toDouble();
}
dataSize = list.size();
}
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include<QFile>
#include<QtCore>
#include<QtGui>
#include<QTextStream>
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
ui->label->setText("Hello User :)");
}
MainWindow::~MainWindow()
{
delete ui;
}
void MainWindow::on_pushButton_clicked()
{
QFile file("C:/ahmad/ecg test/tst.txt");
if(!file.open( QFile::ReadOnly | QFile::Text))
{
ui->label->setText(" OOP : File Cant be Opened");
return;
}
QStringList list;
QTextStream in(&file);
ui->label->setText("DONE : file opened");
while (!in.atEnd())
{
list << in.readLine();
}
file.close();
data = new double[list.size()];
for(int i = 0; i< list.size(); i++)
{
data[i] = list[i].toDouble();
}
dataSize = list.size();
}
To copy to clipboard, switch view to plain text mode
and the errors are:
C:\examples\Plot-build-desktop-Qt_4_8_0_for_Desktop_-_MSVC2010__Qt_SDK__Debug\..\..\Examples\Plot\mainw indow.cpp:38: error: C2248: 'QWidget::data' : cannot access private member declared in class 'QWidget'
C:\examples\Plot-build-desktop-Qt_4_8_0_for_Desktop_-_MSVC2010__Qt_SDK__Debug\..\..\Examples\Plot\mainw indow.cpp:38: error: C2440: '=' : cannot convert from 'double *' to 'QWidgetData *'
Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
C:\examples\Plot-build-desktop-Qt_4_8_0_for_Desktop_-_MSVC2010__Qt_SDK__Debug\..\..\Examples\Plot\mainw indow.cpp:41: error: C2248: 'QWidget::data' : cannot access private member declared in class 'QWidget'
C:\examples\Plot-build-desktop-Qt_4_8_0_for_Desktop_-_MSVC2010__Qt_SDK__Debug\..\..\Examples\Plot\mainw indow.cpp:41: error: C2679: binary '=' : no operator found which takes a right-hand operand of type 'double' (or there is no acceptable conversion)
C:\QtSDK\Desktop\Qt\4.8.0\msvc2010\include\QtGui/qwidget.h(143): could be 'QWidgetData &QWidgetData::operator =(const QWidgetData &)'
while trying to match the argument list '(QWidgetData, double)'
C:\examples\Plot-build-desktop-Qt_4_8_0_for_Desktop_-_MSVC2010__Qt_SDK__Debug\..\..\Examples\Plot\mainw indow.cpp:43: error: C2065: 'dataSize' : undeclared identifier
Bookmarks