Название: Проблема с сигнал-слот. Помогите срочно!!! Отправлено: daimon от Декабря 19, 2009, 13:40 #ifndef GLGRAHF_H
#define GLGRAHF_H #include <QGLWidget> #include <QGLPixelBuffer> #include <QMouseEvent> #include <QKeyEvent> #include <QGLFormat> #include <QTimer> #include <QImage> #include "dataModel.h" class GlGrahf : public QGLWidget { Q_OBJECT private: GLfloat m_xRotate; GLfloat m_yRotate; QTimer *m_timer; GLuint texture[3]; void loadGLTextures(); protected: virtual void initializeGL(); virtual void resizeGL(int nWidth, int nHeight); virtual void paintGL(); virtual void keyPressEvent(QKeyEvent * pe); public slots: void timeOutSlot(); public: GlGrahf(QWidget * pwgt = 0); ~GlGrahf(); }; #endif // GLGRAHF_H #include "GlGrahf.h" GlGrahf::GlGrahf(QWidget *pwgt /*= 0*/) : QGLWidget(pwgt) { m_timer = new QTimer(this); connect(m_timer, SIGNAL(timeout()), this, SLOT(timeOutSlot())); m_timer->start(0); m_xRotate = m_yRotate = 0; } GlGrahf::~GlGrahf() { } void GlGrahf::initializeGL() { //loadGLTextures(); glEnable(GL_TEXTURE_2D); // Enable Texture Mapping glShadeModel(GL_SMOOTH); // Enable Smooth Shading glClearColor(1.0f, 1.0f, 1.0f, 0.5f); // Black Background glClearDepth(1.0f); // Depth Buffer Setup glEnable(GL_DEPTH_TEST); // Enables Depth Testing glDepthFunc(GL_LEQUAL); // The Type Of Depth Testing To Do glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST); // Really Nice Perspective Calculations } void GlGrahf::resizeGL(int nWidth, int nHeight) { if (nHeight==0) // Prevent A Divide By Zero By { nHeight=1; // Making Height Equal One } glViewport(0, 0, (GLint)nWidth, (GLint)nHeight); glMatrixMode(GL_PROJECTION); glLoadIdentity(); gluPerspective(45.0f,(GLfloat)nWidth/(GLfloat)nHeight,0.1f,100.0f); glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix glLoadIdentity(); // Reset The Modelview Matrix } void GlGrahf::loadGLTextures() { QImage t; QImage b; if ( !b.load( "../Data/Crate.bmp" ) ) { b = QImage( 16, 16, QImage::Format_ARGB32); b.fill(Qt::green); } t = QGLWidget::convertToGLFormat( b ); glGenTextures( 3, &texture[0]); glBindTexture( GL_TEXTURE_2D, texture[0] ); glTexImage2D( GL_TEXTURE_2D, 0, 3, t.width(), t.height(), 0, GL_RGBA, GL_UNSIGNED_BYTE, t.bits() ); glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_NEAREST); // ( NEW ) glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_NEAREST); // ( NEW ) glBindTexture( GL_TEXTURE_2D, texture[1] ); glTexImage2D( GL_TEXTURE_2D, 0, 3, t.width(), t.height(), 0, GL_RGBA, GL_UNSIGNED_BYTE, t.bits() ); glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR); glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR); glBindTexture( GL_TEXTURE_2D, texture[2] ); glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR); glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR_MIPMAP_NEAREST); // ( NEW ) gluBuild2DMipmaps(GL_TEXTURE_2D, 3, t.width(), t.height(), GL_RGBA, GL_UNSIGNED_BYTE, t.bits()); // ( NEW ) } void GlGrahf::paintGL() { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glLoadIdentity(); glRotatef(m_xRotate, 1, 0, 0); glRotatef(m_yRotate,0 , 1, 0); glTranslatef(0.0f,0.0f,-5.0f); glColor3f(0,0,0); glBegin(GL_QUADS); glVertex3f(0,1,0); glVertex3f(1,1,0); glVertex3f(1,1,1); glVertex3f(0,1,1); glEnd(); } void GlGrahf::keyPressEvent(QKeyEvent *pe) { // switch(pe->key()){ // case Qt::Key_F1: // x_scale = 1.5; // updateGL(); // break; // } } void GlGrahf::timeOutSlot() { m_xRotate +=0.3f; // X Axis Rotation //m_yRotate +=0.2f; // Y Axis Rotation updateGL(); } ставится как центральный виджет QmainWindow и ошибка (сам виджет работает) Название: Re: Проблема с сигнал-слот. Помогите срочно!!! Отправлено: Dendy от Декабря 19, 2009, 14:50 Покажите весь лог сборки.
Название: Re: Проблема с сигнал-слот. Помогите срочно!!! Отправлено: daimon от Декабря 19, 2009, 15:01 Покажите весь лог сборки. Название: Re: Проблема с сигнал-слот. Помогите срочно!!! Отправлено: Dendy от Декабря 19, 2009, 15:45 Вы забыли дописать в 3DGrahf.pro: HEADERS += GlGrahf.h. Это видно из отсутствия debug/moc_GlGrahf.o в логе линкера.
Название: Re: Проблема с сигнал-слот. Помогите срочно!!! Отправлено: Alex Custov от Декабря 19, 2009, 15:56 Цитировать The Q_OBJECT macro is expanded by the preprocessor to declare several member functions that are implemented by the moc; if you get compiler errors along the lines of "undefined reference to vtable for LcdNumber", you have probably forgotten to run the moc or to include the moc output in the link command. |