Results 1 to 2 of 2

Thread: The -> Operator

  1. #1
    Join Date
    Aug 2007
    Posts
    1
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default The -> Operator

    I'm still rather new to both c++ and qt4, so please bear with me. My question is what exactly does the -> operator do? I've looked in both the Qt4 Tutorial and my copy of the C++ Primer, and I've yet to find anything on it.

    Basically I wish to know why:
    Qt Code:
    1. myButton->setEnabled(!text.isEmtpy());
    To copy to clipboard, switch view to plain text mode 
    differs from:
    Qt Code:
    1. myButton.setEnabled(!text.isEmpty());
    To copy to clipboard, switch view to plain text mode 

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: The -> Operator

    a->b is equivalent of (*a).b (in other words: it allows you to access members of a class or structure if you have a pointer to it).

    In your example, the first myButton variable is a pointer to an object, while the second one is the object itself.

  3. The following user says thank you to jacek for this useful post:

    keifer (11th March 2008)

Similar Threads

  1. Simple: Operator overloading with heap objects
    By durbrak in forum General Programming
    Replies: 12
    Last Post: 25th April 2007, 13:20
  2. QString == Operator
    By ToddAtWSU in forum Qt Programming
    Replies: 1
    Last Post: 27th December 2006, 17:08
  3. Replies: 13
    Last Post: 19th May 2006, 02:10
  4. template parameter and conversion operator
    By bitChanger in forum General Programming
    Replies: 7
    Last Post: 21st April 2006, 15:36
  5. "New" operator
    By vratojr in forum General Programming
    Replies: 1
    Last Post: 21st April 2006, 14:44

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.