pierre58
13th September 2010, 19:06
While learning qt through the book : C++ GUI Programming with qt4, I've encounted this notation quite a few times : function()->function() or function().function().
Here is a common example from : http://doc.qt.nokia.com/4.6/qmainwindow.html (Creating Menus):
void MainWindow::createMenus()
{
fileMenu = menuBar()->addMenu(tr("&File"));
fileMenu->addAction(newAct);
fileMenu->addAction(openAct);
fileMenu->addAction(saveAct);
Usually, in C++, I encounter Classes containing attributes and methods, but when I look at this notation, I see a function containing a function.
I could guess that in this example the menubar() function returns a pointer to a QMenuBar which contains a addMenu() function returning a QMenu, but where is the QMenuBar object coming from? It does not seem to be declared as an attribute of QMainWindow.
How am I supposed interpret this notation ?
Does this notation have a name, if yes what is it ?
Here is a common example from : http://doc.qt.nokia.com/4.6/qmainwindow.html (Creating Menus):
void MainWindow::createMenus()
{
fileMenu = menuBar()->addMenu(tr("&File"));
fileMenu->addAction(newAct);
fileMenu->addAction(openAct);
fileMenu->addAction(saveAct);
Usually, in C++, I encounter Classes containing attributes and methods, but when I look at this notation, I see a function containing a function.
I could guess that in this example the menubar() function returns a pointer to a QMenuBar which contains a addMenu() function returning a QMenu, but where is the QMenuBar object coming from? It does not seem to be declared as an attribute of QMainWindow.
How am I supposed interpret this notation ?
Does this notation have a name, if yes what is it ?