[Qt-interest] multiple glwidget interaction

Sajjad dosto.walla at gmail.com
Wed Jul 7 15:32:44 CEST 2010


Hello John,

I have declared a SharedWidgetData class that contains all  the matrices
that need to be shared between 2 gl widgets.

Then i created a singleton class and instantiate one instance of the
SharedWidgetData  in the constructor of the top level window constructor as
follows:


******************************************************************************
Singleton<SharedWidgetData>::init(new SharedWidgetData());

******************************************************************************

Then i send the pointers of the newly instantiated object to both the
widgets so that both the widgets can access and update the matrices as
necessary.

But the program crashes and while debugging it i found that the program
gives a segmentation fault in the above line.  Singleton class is full-proof
i believe since it has been used in another API and it has been quite
functional so far.



Any hint to track  the issue?


Regards
Sajjad





On Tue, Jul 6, 2010 at 8:54 PM, John McClurkin <jwm at nei.nih.gov> wrote:

> Sajjad wrote:
> > Hello forum,
> >
> > I have two separate classes inherited from QGLWidget and both  the
> > classes need to share and update the projection , modelview and inverse
> > matrices . These matrices are defines as follows:
> >
> > I get  the modelview matrix by
> >
> > glGetDoublev(GL_MODELVIEW_MATRIX, modelview); And that modelview matrix
> > will be shared and updated by both the QGLWidget subclasses. I need to
> > have the following matrices declared, but not sure where to declare them.
> >
> > GLdouble modelview[16]
> > GLdouble projection[16]
> > GLdouble inverse[16]
> >
> >
> > I have declared the above matrices in one of the widget and i need to
> > pass the contents of these matrices to another gl widget. Do i have to
> > declare another three arrays in that widget as well?
> >
> >
> > I also need to set several signal and slots, like when ever the any of
> > the matrices changes the matrices will be passed with  the corresponding
> > slots. The slots may be of the same widget or the other widget.
> >
> >
> >
> I would define a class containing the three arrays with functions to get
> and set their values and signals that could be emitted by those
> functions whenever the values were accessed. Then instantiate just one
> instance of that class.
> _______________________________________________
> Qt-interest mailing list
> Qt-interest at trolltech.com
> http://lists.trolltech.com/mailman/listinfo/qt-interest
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20100707/4e506372/attachment.html 


More information about the Qt-interest-old mailing list