Results 1 to 3 of 3

Thread: small clarification regarding & operator

  1. #1
    Join Date
    Jan 2012
    Posts
    20
    Thanks
    3

    Default small clarification regarding & operator

    Hi all,

    i found the following code in one of the examples paintBackground(QPainter & painter), sorry i am new to C++ and QT. I understand you are actually passing the address of the painter object. But in "C" programming language the address is passed through "*" operator. But in some functions in QT I observed the following notation also void paintEvent(QPaintEvent * ). Are both same. am i asking stupid question? But for somebody is it possible to explain?

    thanks in advance,

    regards,
    Satya
    Last edited by wysota; 15th February 2012 at 10:34.

  2. #2
    Join Date
    Oct 2010
    Location
    Berlin, Germany
    Posts
    358
    Thanks
    18
    Thanked 68 Times in 66 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: small clarification regarding & operator

    Hi,

    "QPainter& painter" is a reference.
    "QPainter* painter" is a pointer.

    This is indeed a bit confusing since the "operator&" reurns the adress of an object which can be assigned to a pointer. But in the declaration above, the "&" is not an operator.

    Felix

  3. #3
    Join Date
    Jan 2012
    Posts
    20
    Thanks
    3

    Default Re: small clarification regarding & operator

    Hi,

    Thank you for the reply. I have studied for call by reference in the net and i found that C does not support call by reference whereas C++ supports and hence the declaration difference when compared to C.

    Thanks and regards,
    Satya

Similar Threads

  1. MoveToThread clarification
    By Thuan Seah Tan in forum Qt Programming
    Replies: 1
    Last Post: 3rd February 2012, 10:32
  2. QThread clarification
    By janorcutt in forum Qt Programming
    Replies: 5
    Last Post: 6th January 2011, 09:11
  3. Clarification on how to use Qt's debugging techniques
    By hackerNovitiate in forum Newbie
    Replies: 5
    Last Post: 21st June 2010, 04:08
  4. Replies: 0
    Last Post: 21st September 2009, 17:25
  5. Clarification about dataChanged
    By airbites in forum Qt Programming
    Replies: 2
    Last Post: 29th July 2009, 16:02

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.