Results 1 to 6 of 6

Thread: to call member function

  1. #1
    Join Date
    May 2011
    Posts
    120
    Thanks
    33
    Qt products
    Qt4
    Platforms
    Windows

    Default to call member function

    How to call a member function from another class without creating an object ?

  2. #2
    Join Date
    Sep 2009
    Location
    Wroclaw, Poland
    Posts
    1,391
    Thanked 342 Times in 324 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: to call member function

    You cannot call member function without an object. What if inside the method this pointer is used ? You can call only public static methods without objects.

  3. #3
    Join Date
    May 2011
    Posts
    120
    Thanks
    33
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: to call member function

    then how can we call it with an object. can you give me an ex:

  4. #4
    Join Date
    Sep 2009
    Location
    UK
    Posts
    2,447
    Thanks
    6
    Thanked 348 Times in 333 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: to call member function

    Seriously? This is extremely basic C++, knowledge of which is required to use Qt.

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

    Default Re: to call member function

    ok, some very very basic c++ beginner code:

    Qt Code:
    1. CObject myObject;
    2. myObject.myMemberMethod();
    To copy to clipboard, switch view to plain text mode 

  6. #6
    Join Date
    Sep 2009
    Location
    Wroclaw, Poland
    Posts
    1,391
    Thanked 342 Times in 324 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: to call member function

    Come on, I can't imagine someone to dig into Qt without such knowledge, this is ... simply impossible...

Similar Threads

  1. cannot call member function without object
    By been_1990 in forum Qt Programming
    Replies: 11
    Last Post: 23rd October 2010, 17:12
  2. Replies: 1
    Last Post: 8th October 2010, 11:38
  3. Replies: 2
    Last Post: 7th July 2009, 17:44
  4. Replies: 10
    Last Post: 29th May 2009, 09:06
  5. How to call the C++ member function from the JScript
    By parusri in forum Qt Programming
    Replies: 1
    Last Post: 18th October 2008, 10:13

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.