[Qt-creator] Sharing GL ctx with qt-designer.

eike.ziller at nokia.com eike.ziller at nokia.com
Tue Jun 19 14:48:21 CEST 2012


On 19 Jun 2012, at 12:39, ext Paulo Silva wrote:

> Hi everyone,
> 
> I have a question wich is more about the qt-designer functionality of
> qt-creator, so this might actually be the wrong mailing list - if so,
> sorry about that.
> 
> My question is how can we share an OGL context between two or more
> QGLWidgets, when the interface is made using the design mode?.
> That is, since I'm not creating the widgets myself, how can I take the
> context of one of the widgets and share it with the other widgets?
> I tried to create to create class members like:
> static QGLContext* const _shared_context(new QGLContext(QGLFormat()));
> static QGLWidget* _shared_widget(initialized to the first widget created...);
> 
> and tried to pass it to the constructor,
> MyClass():
>   QGLWidget(_shared_context, parent, _shared_widget),
> {
> (...)
> }
> 
> But it does not seem to work as isSharing returns false, and nothing
> updateGL fails drawing nothing.
> 
> Is there a correct way of doing this? Any designer functionality?

Would probably be better asked on the interest@ mailing list, anyhow, trying to point to potential problems:

So, you "promoted" all your widgets in designer to "MyClass"?

> static QGLContext* const _shared_context(new QGLContext(QGLFormat()));
If you really do that, you create a new QGLContext for each _shared_context() call. But that doesn't look like "real" code, so I suppose you return a single static instance here?

> MyClass():
I'd think that designer generates code that calls a constructor that takes a "QWidget *parent". Is your constructor actually called? What does the generated ui_*.h file actually do? Have you debugged what is actually called with what parameters?

All in all I believe your approach could work in principal, it's hard to say what's going wrong specifically without seeing the actual code.

Br, Eike

-- 
Eike Ziller
Principal Software Engineer

Nokia, Qt Development Frameworks

Nokia gate5 GmbH
Firmensitz: Invalidenstr. 117, 10115 Berlin, Germany
Registergericht: Amtsgericht Charlottenburg, Berlin: HRB 106443 B
Umsatzsteueridentifikationsnummer: DE 812 845 193
Geschäftsführer: Dr. Michael Halbherr, Karim Tähtivuori




More information about the Qt-creator mailing list