How can I show a blank QGLWidget as a popup?



  • I already have a main window with a number of widgets and a QGLWidget on it.

    I want to create another QGLWidget which opens as a new window.

    ProjectedHand.h
    @#ifndef _GLWIDGET_H
    #define _GLWIDGET_H

    #include <QtOpenGL/QGLWidget>
    #include <QDebug>

    class ProjectedHand : public QGLWidget {

    Q_OBJECT // must include this if you use Qt signals/slots
    

    public:
    ProjectedHand(QWidget *parent = NULL);

    protected:
    void initializeGL();
    void resizeGL(int w, int h);
    void paintGL();
    };

    #endif /* _GLWIDGET_H */@

    ProjectedHand.cpp
    @#include <QtGui/QMouseEvent>
    #include "ProjectedHand.h"

    ProjectedHand::ProjectedHand(QWidget *parent) : QGLWidget(parent) {

    }

    void ProjectedHand::initializeGL() {
    glClearColor(1.0f, 1.0f, 1.0f, 1.0f);
    }

    void ProjectedHand::resizeGL(int w, int h) {

    }
    void ProjectedHand::paintGL() {
    static bool screenOnBlank = false;
    if (!screenOnBlank) {
    qDebug("Painting grey-ness");
    glClearColor(1.0f, 1.0f, 1.0f, 1.0f);
    glClear(GL_COLOR_BUFFER_BIT);
    screenOnBlank = true;
    }
    }@

    Then, from another class, I call:
    @ProjectedHand *window = new ProjectedHand(NULL);
    window->resize(800,600);
    window->show();@

    It gives me a popup, but the window is not blank. It's a window containing a distorted view of what I see on my main window.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.