Thread: Clarification for a complicated syntax

  1. #1
    [](){}(); manasij7479's Avatar
    Join Date
    Feb 2011
    Location
    *nullptr
    Posts
    2,657

    Clarification for a complicated syntax

    In the QT4 documentations, I'm frequently seeing statements like..
    Code:
    fileMenu = menuBar()->addMenu(tr("&File"));
    I am assuming that menuBar() returns a pointer to an object..(Does it?)
    What happens after that ..is not comprehensible by me.
    Any simple explanation ?

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,661
    It's like this, without the extra variables
    Code:
    currentMenuBar = menuBar(); 
    fileMenu = currentMenuBar->addMenu(tr("&File"));
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  3. #3
    [](){}(); manasij7479's Avatar
    Join Date
    Feb 2011
    Location
    *nullptr
    Posts
    2,657
    ...now I see...
    and then
    Code:
    addMenu(tr("&File"));
    returns something, which becomes the rvalue ...

  4. #4
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,661
    Sure, tr() returns something that addMenu() will accept as a parameter, and it returns a fileMenu value.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Probably way too complicated for me.
    By Necrofear in forum Windows Programming
    Replies: 3
    Last Post: 05-21-2006, 05:41 AM
  2. Complicated Hello World
    By skorman00 in forum C Programming
    Replies: 7
    Last Post: 07-04-2004, 02:43 AM
  3. complicated
    By ZakkWylde969 in forum A Brief History of Cprogramming.com
    Replies: 14
    Last Post: 07-12-2003, 09:15 AM
  4. Nothing complicated, just...
    By SMurf in forum Windows Programming
    Replies: 1
    Last Post: 09-01-2002, 05:59 PM
  5. pretty complicated
    By soaponarope in forum C++ Programming
    Replies: 5
    Last Post: 08-31-2002, 03:21 PM