Clarification for a complicated syntax

This is a discussion on Clarification for a complicated syntax within the C++ Programming forums, part of the General Programming Boards category; In the QT4 documentations, I'm frequently seeing statements like.. Code: fileMenu = menuBar()->addMenu(tr("&File")); I am assuming that menuBar() returns a ...

  1. #1
    Registered User manasij7479's Avatar
    Join Date
    Feb 2011
    Location
    Kolkata@India
    Posts
    2,498

    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 ?
    Manasij Mukherjee | gcc-4.8.2 @Arch Linux
    Slow and Steady wins the race... if and only if :
    1.None of the other participants are fast and steady.
    2.The fast and unsteady suddenly falls asleep while running !



  2. #2
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,673
    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.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  3. #3
    Registered User manasij7479's Avatar
    Join Date
    Feb 2011
    Location
    Kolkata@India
    Posts
    2,498
    ...now I see...
    and then
    Code:
    addMenu(tr("&File"));
    returns something, which becomes the rvalue ...
    Manasij Mukherjee | gcc-4.8.2 @Arch Linux
    Slow and Steady wins the race... if and only if :
    1.None of the other participants are fast and steady.
    2.The fast and unsteady suddenly falls asleep while running !



  4. #4
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,673
    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.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21