Results 1 to 5 of 5

Thread: rtti() of derived class

  1. #1
    Join Date
    Apr 2006
    Posts
    122
    Thanks
    18
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default rtti() of derived class

    Here is small pbm i am facing.

    I have deriver a MyCanvasItem class from Q3CanvasPolygonal class.
    i have overridded rtti() to return specific value.
    But it clicking on this MyCanvasItem is return 2i.e. Q3CanvasPolygonal::RTTI.

    where i can improve upon.

    quickNitin

  2. #2
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: rtti() of derived class

    Is it declared virtual in the base class (Q3CanvasPolygonal)? Does the signature of the function match exactly (including constness)?
    J-P Nurmi

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

    quickNitin (8th October 2006)

  4. #3
    Join Date
    Apr 2006
    Posts
    122
    Thanks
    18
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: rtti() of derived class

    ya there was some difference. Now it works

    in Q3CanavsPolygonal class it is defined as
    virtual int rtti() const{}

    but i declared it as member
    virtual const int rtti() {}. How this declaration is diffrent from above? I am not awar of difference. It has become now C++ doubt.

    now i had declare rtti() very same as in parent class and now it is working.

    thanks jpn

  5. #4
    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: rtti() of derived class

    Quote Originally Posted by quickNitin View Post
    in Q3CanavsPolygonal class it is defined as
    virtual int rtti() const{}

    but i declared it as member
    virtual const int rtti() {}. How this declaration is diffrent from above?
    First one is a "const" (i.e. non-mutating) method that returns an integer, while second one is a normal method that returns a constant integer.

    In short: "const" methods can't change member variables and therefore they can be invoked on constant objects.

    http://www.parashift.com/c++-faq-lit...rrectness.html

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

    quickNitin (8th October 2006)

  7. #5
    Join Date
    Apr 2006
    Posts
    122
    Thanks
    18
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: rtti() of derived class

    thanks jacek
    its working well now!

Similar Threads

  1. Signal/slot looking in base class, not derived class
    By georgie in forum Qt Programming
    Replies: 2
    Last Post: 12th May 2006, 07:36
  2. Replies: 2
    Last Post: 4th May 2006, 19:17
  3. Qt in other class
    By Morea in forum Qt Programming
    Replies: 4
    Last Post: 9th April 2006, 17:08
  4. How to propagate from one class to another
    By mahe2310 in forum Qt Programming
    Replies: 15
    Last Post: 20th March 2006, 01:27
  5. Replies: 5
    Last Post: 15th March 2006, 07:33

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.