hi
i am trying to print a no. o points on canvas. These points are read from a fifo through a clas MyThread.
{
Q_OBJECT
public:
~MyThread();
double x;
double y;
protected:
void run();
signals:
void dataAvailable();
public slots:
void startThread();
};
#endif
class MyThread: public QThread
{
Q_OBJECT
public:
MyThread(QObject *parent=0);
~MyThread();
double x;
double y;
protected:
void run();
signals:
void dataAvailable();
public slots:
void startThread();
};
#endif
To copy to clipboard, switch view to plain text mode
amd its implementation is as
#ifndef MYTHREAD_cpp
#define MYTHREAD_cpp
#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include "MyThread.h"
#include <iostream.h>
{
}
MyThread::~MyThread()
{
}
void MyThread::run()
{
int fd0;
fd0 = open("/home/prince/mydev01",O_RDWR);
if(fd0== -1)
cout<<"\n------------------- No fifo found///////---------------------\n\n";
else
cout<<" Fifo founf \n";
read(fd0,&x,sizeof(int));
read(fd0,&y,sizeof(int));
printf("\nReceived x = %d & y = %d from RTCore\n",
x,y);
close(fd0);
emit dataAvailable();
}
void MyThread::startThread()
{
start(LowPriority);
}
#endif
#ifndef MYTHREAD_cpp
#define MYTHREAD_cpp
#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include "MyThread.h"
#include <iostream.h>
MyThread::MyThread(QObject *parent) :QThread(parent)
{
}
MyThread::~MyThread()
{
}
void MyThread::run()
{
int fd0;
fd0 = open("/home/prince/mydev01",O_RDWR);
if(fd0== -1)
cout<<"\n------------------- No fifo found///////---------------------\n\n";
else
cout<<" Fifo founf \n";
read(fd0,&x,sizeof(int));
read(fd0,&y,sizeof(int));
printf("\nReceived x = %d & y = %d from RTCore\n",
x,y);
close(fd0);
emit dataAvailable();
}
void MyThread::startThread()
{
start(LowPriority);
}
#endif
To copy to clipboard, switch view to plain text mode
I need to refresh view every second. So a Timer generates a signal everysecond to run some code to claa slot MyThread::startThread(). Control reaches and it also goes to run(). But either it donot enters run() ( i checked it with gdb breakpoint method) or before reads it again comes to MyThread::startThread().
I couldn't figure out the cause
Bookmarks