Hi there ,
I have a QThread which is worker thread that supllying some data to QGLWidget. I made a signal completed on QThread. I wanna connect that signal with QGLWidget its DrawME Slot is it posssible to connect these Object with this way ?
{
public:
myThread
(MainWindow
*that
) : QThread(0) { m_MW = that; // i'm getting MainThread with that way i guess it's not good way ....
}
void run()
{
...
...
BYTE *pDib = (BYTE *)m_MW->myImage->imageData;
int w = m_MW->myImage->width;
int h = m_MW->myImage->height;
emit (completed(pDib,w,h));
}
signals:
void completed(BYTE *, int, int){}
private :
MainWindow *m_MW;
};
class myThread : public QThread
{
public:
myThread(MainWindow *that) : QThread(0) {
m_MW = that; // i'm getting MainThread with that way i guess it's not good way ....
}
void run()
{
...
...
BYTE *pDib = (BYTE *)m_MW->myImage->imageData;
int w = m_MW->myImage->width;
int h = m_MW->myImage->height;
emit (completed(pDib,w,h));
}
signals:
void completed(BYTE *, int, int){}
private :
MainWindow *m_MW;
};
To copy to clipboard, switch view to plain text mode
GLWidget
{
Q_OBJECT
public:
void setTextureData(BYTE *data, int width, int height);
public slots:
void DrawME(BYTE * data, int width, int height);
private:
void initializeGL();
void resizeGL(int w, int h);
GLuint m_pTextureId;
};
class GLWidget : public QGLWidget
{
Q_OBJECT
public:
GLWidget(QWidget *parent = 0);
void setTextureData(BYTE *data, int width, int height);
public slots:
void DrawME(BYTE * data, int width, int height);
private:
void initializeGL();
void resizeGL(int w, int h);
GLuint m_pTextureId;
};
To copy to clipboard, switch view to plain text mode
myThread *t = new myThread(this);
QObject::connect(t,
SIGNAL(completed
(BYTE
*,
int,
int)), ui
->widget,
SLOT(DrawME
(BYTE
*,
int,
int)));
t->start();
myThread *t = new myThread(this);
QObject::connect(t, SIGNAL(completed(BYTE*,int,int)), ui->widget, SLOT(DrawME(BYTE*,int,int)));
t->start();
To copy to clipboard, switch view to plain text mode
after t->start it works well signal is emitting but Slot DrawMe is not working , Could you gimme right way for connection slot and signals , thanks for help
Bookmarks