Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. How can I show a blank QGLWidget as a popup?
Qt 6.11 is out! See what's new in the release blog

How can I show a blank QGLWidget as a popup?

Scheduled Pinned Locked Moved General and Desktop
1 Posts 1 Posters 645 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P Offline
    P Offline
    prerna1
    wrote on last edited by
    #1

    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.

    1 Reply Last reply
    0

    • Login

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt Extensions
    • Unsolved