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.

    @#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

    ProjectedHand(QWidget *parent = NULL);

    void initializeGL();
    void resizeGL(int w, int h);
    void paintGL();

    #endif /* _GLWIDGET_H */@

    @#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);
    screenOnBlank = true;

    Then, from another class, I call:
    @ProjectedHand *window = new ProjectedHand(NULL);

    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.