initializeGL() never called after updates Qt4.8 -> Qt5.X



  • Hello,

    I have a problem with my application. When I open my window, it is frozen. This problem has shown itself recently after my porting (Qt4.8 -> Qt5.3)

    The library used with Qt4.8, compiler msvc9:

    • qt 4.8.6
    • qwt 6.1.1
    • ftgl 2.1.2
    • glew 1.5.1

    The library used with Qt5.3, compiler msvc12:

    • qt 5.3.2
    • qwt 6.1.1
    • ftgl 2.1.3
    • glew 1.11.0

    The same code is functional before porting. The methods initializeGL(), paintGL() are called
    After porting my method initializeGL() is never called.

    Can you help me... (because I haven't internet on my dev computer, this code isn't free of errors.

    //GLWidget.cpp
    GLWidget::GLWidget(QWidget* parent):
       QGLWidget(QGLFormat(QGL::DoubleBuffer), parent),
       _owner(NULL)
    {
       setAttribute(::Qt::WA_AcceptTouchEvents);
    }
    
    GLWidget::~GLWidget()
    {
       //Do nothing
    }
    
    GLWidget::setOwner(WindowsBase* owner)
    {
       _owner = owner;
    }
    
    GLWidget::initializeGL()
    {
       //Do nothing
    }
    
    GLWidget::paintGL()
    {
       _owner->InternalOnDraw();
    }
    
    GLWidget::resizeGL(DAint32 width, DAint32 height)
    {
       _owner->InternalOnResize(width, height);
    }
    
    GLWidget::event(QEvent* event)
    {
       bool event_consumed = false;
       switch(event->type())
       {
          case QEvent::TouchBegin:
          case QEvent::TouchUpdate:
             {
                //processing
                break;
             }
       }
    }
    
    //Window.cpp
    Window::Window()
    {
       //Do nothing
    }
    
    Window::~Window()
    {
       //Do nothing
    }
    
    Window::create()
    {
       if(!_window)
       {
          _window = allocateWindow();
          _window->setWindowFlags(::Qt::FramelessWindowHint | ::Qt::CustomizeWindowHint | ::Qt::WindowStaysOn);
       }
       _window->setWindowTitle("title");
       _window->move(0, 0);
       _window->resize(500, 500);
    }
    
    Window::destroy()
    {
       delete _window;
       _window = NULL;
    }
    
    Window::show()
    {
       _window->show();
       _window->raise();
    }
    
    Window::hide()
    {
       _window->hide();
    }
    
    Window::redraw()
    {
       _window->update();
    }
    
    Window::exit()
    {
       _window->close();
    }
    
    //{...}
    
    QWidget*
    Window::allocateWindow()
    {
       QWidget* main_window = new QWidget();
       main_window->setOwner(this);
       _glWidget = new QGLWidget();
       _glWidget->setOwner(this);
    
       QHBoxLayout* mainLayout = new QHBoxLayout();
       mainLayout->setContentsMargins(0, 0, 0, 0);
       mainLayout->   addWidget(_glWidget);
       main_window->setLayout(mainLayout)
       return main_window;
    }
    
    QWidget*
    Window::getMainWindow()
    {
       return _window;
    }
    

    With msvc9 :
    When I open this window, I have the event QEvent::Resize() and QEvent::Move().
    My method initializeGL() is called.
    After I have the events QEvent::Show, QEvent::ShowToParent and QEvent::WindowActivate.

    With msvc12 :
    When I open this window, I have the events QEvent::Resize() and QEvent::Move().
    My method initializeGL() isn't called.
    Like with msvc9 I have after the events QEvent::Show, QEvent::ShowToParent and QEvent::WindowActivate.

    I would be happy to receive any ideas or propositions in order to develop our reflections on this issue.

    Now I try the method isValid on my GLWidget, and it return me "0". So my widget haven't OpenGL support. But why with msvc9 I have this OpenGL support and I haven't it with msvc12 and the update of my library ????

    Thank you
    e822104



  • I don't know if this is related but I did notice recently that the initialize member will only get called if a widget is visible (i.e. about to become visible for the first time).. I don't know if it worked this way in Qt 4.x but I noticed it in 5.6.





  • I continue to look for my problem.

    For analyze the difference between this 2 version, I read the version number of my library OpenGL.

    With msvc9.0 :

    • version = 127103(0x0001F07F) : OpenGL 4.0, but not OpenGL ES2
      With msvc12.0 :
    • version = 2048 (0x00000800) : OpenGL ES2

    My question is :
    How do I compile my Qt library for call only OpenGL 4.0 ?

    configure -prefix %CD%\qtbase -opensource -opengl dynamic ???

    Thank you

    @e822104



  • Problem solved

    I use Qt5.5.1 compilated with -opengl dynamic.

    configure -prefix %CD%/qtbase -opengl dynamic
    

    Thank you for your help.

    e822104



  • i have a different problem, but i'm sure it's something about configuration, too.
    I used qt 5.7 first with configure -OpenGL desktop
    and now i use 5.8 with
    -OpenGL dynamci -release-and-debug -nomake examples -skip doc

    When i run my program in debug configuration everything is fine. But in release the OpenGL widget is not created and my QStylesheet does not work either. Any ideas about that??


Log in to reply
 

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