in Education by
I have a simple UI with a button, after pressing the button I should open a new window where OpenGL stuff should be drawn. I'm trying to do this with QOpenGLWidget but the InitializeGL() and paintGL() functions are never called. So basically I have my main with a function that should start everything: void test::displayOpenGLObjects { newOpenGLContext = std::make_unique(this); } Visualization_OpenGL.cpp test::Visualization_OpenGL(QWidget *parent): QOpenGLWidget(parent) { QOpenGLWidget *test_window = new QOpenGLWidget(); test_window->setWindowTitle("OpenGL Visualization"); test_window->makeCurrent(); test_window->show(); } test::initializeGL(){ ... } test::paintGL(){ ... } test::resizeGL(){ ... } And the header: class Visualization_OpenGL : public QOpenGLWidget, public QOpenGLFunctions { Q_OBJECT public: Visualization_OpenGL(QWidget *parent); ~Visualization_OpenGL(); protected: void initializeGL() override; void resizeGL(int w, int h) override; void paintGL() override; }; The examples I've seen all draw everything on the mainwindow, and when I do it like that, the paintGL() and initializeGL() are indeed called, but I need to have a separate window for this, I'm guessing my problem is something involving the QOpenGLWidget *test_window = new QOpenGLWidget(); but I'm not sure how to fix. I'm super new with this so I'm sorry if this is a super noob question, but any help will be appreciated. JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)

1 Answer

0 votes
by
It is strange to open one widget in the constructor of another. You can create a new widget in a button click slot. For example: void MainWindow::OnButtonClicked() { Visualization_OpenGL* test_window = new Visualization_OpenGL(); test_window->setWindowTitle("OpenGL Visualization"); test_window->makeCurrent(); test_window->show(); } Then Visualization_OpenGL::initializeGL, Visualization_OpenGL::resizeGL and Visualization_OpenGL::paintGL will be invoked.

Related questions

0 votes
    So my question is targeted currently at Windows, but knowing the information for OSX would still be useful ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 7, 2022 in Education by JackTerrance
0 votes
    I'd like to ensure my RAII class is always allocated on the stack. How do I prevent a class from ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 17, 2022 in Education by JackTerrance
0 votes
    I'd like to ensure my RAII class is always allocated on the stack. How do I prevent a class from ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 17, 2022 in Education by JackTerrance
0 votes
    To start with the new package in RStudio, double-click the pkgname.Rproj file that _______ (a) Delete() ... of R Programming Select the correct answer from above options...
asked Feb 11, 2022 in Education by JackTerrance
0 votes
    I am trying to run a .bat file in a new window so the user of the PC can input commands, ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 26, 2022 in Education by JackTerrance
0 votes
0 votes
    I am working on a C++ program, which uses cURL library, which is written in plain C. When I try ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Aug 1, 2022 in Education by JackTerrance
0 votes
    I am writing a program that uses the XGetPixel() method. However, upon using it I get an error ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jul 27, 2022 in Education by JackTerrance
0 votes
    This is the document of the function cv::fisheye::initUndistortRectifyMap I don't know what the R is. ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jul 20, 2022 in Education by JackTerrance
0 votes
    All compilers I could get my hands on agree that this is fine: template auto foo(Check, T...) - ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jul 14, 2022 in Education by JackTerrance
0 votes
    Let's say that I declare a C struct called foo, which has an int field called bar and a char * ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jul 8, 2022 in Education by JackTerrance
0 votes
    I want to be able to zoom in my QtCharts using the mouse. The best way to zoom using the mouse ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jul 6, 2022 in Education by JackTerrance
0 votes
    I work on graphics applications and have been using shared & unique pointers essentially because it handles memory ... for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jun 30, 2022 in Education by JackTerrance
0 votes
    Closed. This question needs to be more focused. It is not currently accepting answers. Want to improve this ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jun 30, 2022 in Education by JackTerrance
0 votes
    I have a QGraphicsItem element (subclassesed from QGraphicsItem) that has as child a QGraphicsTextItem. The problem ... for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jun 16, 2022 in Education by JackTerrance
...