PDA

View Full Version : How to access MainWindow objects.



Doug Broadwell
2nd November 2006, 20:08
I'm not only a Qt newbe but also a C++ newbe so... lots of dumb questions (as someone famous once said [about someone else] - "I'm a humble man, with a lot to be humble about").

I have a main window with a bunch of widgets on it that I can access within the implementation of the main window. How can I access these widgets from other functions/objects? Do I need to implement a "getWidgetPointer()" access function to call from my other code?

Also, how do I make my mainwindow instance which is created in my main() function global (or otherwise accessable)?

Thanks

high_flyer
3rd November 2006, 10:03
That is indeed a C++ (or OOP) question.
In general, yes, usually you create access member functions to set and get values of class members.
For private/protected class members it is a must, for public class members you don't HAVE to do it, you can access public members directly so: pointerTomyObject->objectMember = value;