#include"MyDialog.h"
#include<iostream>
#include<QTimer>
#include<QString>
#include<QFile>
using namespace std;
MyDialog::MyDialog()
{
setupUi(this);
connect(this,SIGNAL(yesAvailable()),this,SLOT(readDataHere()));
connect(checkBox,SIGNAL(clicked()),this,SLOT(openFile()));
connect(this,SIGNAL(dataFound()),this,SLOT(receiveOnRead()));
flag=false;
}
MyDialog::~MyDialog()
{
}
void MyDialog::openFile()
{ if(flag==false)
{
flag=true;
fifoFile.setFileName("/home/prince/mydev01");
cout<<"Error in opening the fifofile"<<endl;
else
{ cout<<"File opened\n";
connect(&fifoFile,SIGNAL(readyRead()),this,SLOT(readDataHere()));
connect(t,SIGNAL(timeout()),this,SLOT(checkingAvailability()));
t->start(1001);
}
}
}
void MyDialog::checkingAvailability()
{ long x;
if(fifoFile.canReadLine())
cout<<" \n YA can read line";
else
cout<<" \n Can't read line:";
x=fifoFile.bytesAvailable();
cout<<"\t No of bytes available"<<x<<"\t";
if(x>0)
{
emit yesAvailable();
}
}
void MyDialog::receiveOnRead()
{
sx.setNum(x);
sy.setNum(y);
label
->setText
(sx
+QString(" ") +sy
);
cout<<"\n From dialog "<<x<<" "<<y<<endl;
}
void MyDialog::readDataHere()
{
if(fifoFile.canReadLine())
cout<<" \n YA can read line";
bool conversionErrorFlag;
x=temp.toInt(&conversionErrorFlag);
temp=fifoFile.read(2);
cout<<"\t "<<x;
y=temp.toInt(&conversionErrorFlag);
emit dataFound();
}
#include"MyDialog.h"
#include<iostream>
#include<QTimer>
#include<QString>
#include<QFile>
using namespace std;
MyDialog::MyDialog()
{
setupUi(this);
connect(this,SIGNAL(yesAvailable()),this,SLOT(readDataHere()));
connect(checkBox,SIGNAL(clicked()),this,SLOT(openFile()));
connect(this,SIGNAL(dataFound()),this,SLOT(receiveOnRead()));
flag=false;
}
MyDialog::~MyDialog()
{
}
void MyDialog::openFile()
{ if(flag==false)
{
flag=true;
fifoFile.setFileName("/home/prince/mydev01");
if(!fifoFile.open(QIODevice::ReadOnly))
cout<<"Error in opening the fifofile"<<endl;
else
{ cout<<"File opened\n";
connect(&fifoFile,SIGNAL(readyRead()),this,SLOT(readDataHere()));
QTimer *t=new QTimer(this);
connect(t,SIGNAL(timeout()),this,SLOT(checkingAvailability()));
t->start(1001);
}
}
}
void MyDialog::checkingAvailability()
{ long x;
if(fifoFile.canReadLine())
cout<<" \n YA can read line";
else
cout<<" \n Can't read line:";
x=fifoFile.bytesAvailable();
cout<<"\t No of bytes available"<<x<<"\t";
if(x>0)
{
emit yesAvailable();
}
}
void MyDialog::receiveOnRead()
{
QString sx;
sx.setNum(x);
QString sy;
sy.setNum(y);
label->setText(sx+QString(" ") +sy);
cout<<"\n From dialog "<<x<<" "<<y<<endl;
}
void MyDialog::readDataHere()
{
if(fifoFile.canReadLine())
cout<<" \n YA can read line";
QByteArray temp=fifoFile.read(2);
bool conversionErrorFlag;
x=temp.toInt(&conversionErrorFlag);
temp=fifoFile.read(2);
cout<<"\t "<<x;
y=temp.toInt(&conversionErrorFlag);
emit dataFound();
}
To copy to clipboard, switch view to plain text mode
Bookmarks