You almost have it :-)

Originally Posted by
pierre58
I could guess that in this example the menubar() function returns a pointer to a QMenuBar
To a QMenuBar object to be more specific.
but where is the QMenuBar object coming from? It does not seem to be declared as an attribute of QMainWindow.
Not all the class child objects or functions are publicly available. The menu bar for example is a private object inside the main window. You use access functions to reach them.
The menuBar() function returns the menu bar object.
class MyClass
{
public:
MyObject *getMyObject() const;
private:
MyObject *theObject;
};
MyObject *MyClass::getMyObject() const
{
return theObject;
}
...
MyClass *myclass = new MyClass(...);
MyObject *theObjectFromMyClass = myclass->getMyObject();
class MyClass
{
public:
MyObject *getMyObject() const;
private:
MyObject *theObject;
};
MyObject *MyClass::getMyObject() const
{
return theObject;
}
...
MyClass *myclass = new MyClass(...);
MyObject *theObjectFromMyClass = myclass->getMyObject();
To copy to clipboard, switch view to plain text mode
Bookmarks