PDA

View Full Version : problem using dialog to control a glwidget in a main window



rucs_hack
12th August 2010, 18:55
I've got an application that has a main window with a glWidget and sliders (as in helloGL), and a second window alongside it that has the controls to manipulate the GL widget's content.

That is, I have the interface built. Where I'm stuck is that I can't work out how to share variables between the two windows so I can communicate changes to the glWidget context from the controls window.

This is likely an issue with my not yet grasping how QT works. I'm sure there must be a way to communicate between windows, but I can't see it.

Any help/pointers would be much apreciated.

Zlatomir
12th August 2010, 19:10
You can use signals and slots (http://doc.trolltech.com/4.6/signalsandslots.html)

rucs_hack
12th August 2010, 20:47
I looked at that, but I didn't know how to make the dialog class aware of the glWidget. I may need to study signals/slots a bit more. by 'I may' I of course mean 'absolutelly must...'

Think I solved it for the moment, I passed a pointer to the glWidget as a parameter to the control dialogs constructor. That's probably a cheap hack that misses a major point of QT, but it works.

I'll change it to use signals and slots as soon as I can figure them out. Thanks for the help, and the link.

Zlatomir
12th August 2010, 20:50
You can code signals and slots to the main window widget (first window), so that you expose whatever functionality you want to call from the dialog (or second window)

rucs_hack
12th August 2010, 20:53
You can code signals and slots to the main window widget (first window), so that you expose whatever functionality you want to call from the dialog (or second window)

That would seem to make the most sense. Frantically reading the signals/slots link right now. Quite how I managed to get this far into QT without learning about them is beyond me. Mind you, I mainly do CLI.

rucs_hack
12th August 2010, 22:51
Oh dear. Now I've got to grips with signals and slots I have a severe case of 'buggrit I'm an idiot' going on....