Results 1 to 4 of 4

Thread: inheritence and virtual

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    May 2010
    Location
    Romania
    Posts
    1,021
    Thanks
    62
    Thanked 260 Times in 246 Posts
    Qt products
    Qt5
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: inheritence and virtual

    You need to use pointers to achieve that, something like this:
    Qt Code:
    1. QList<PathPiece*> list;
    To copy to clipboard, switch view to plain text mode 
    you are truncating your values if you don't.

    So: Base obj = Derived objD; //isn't valid it performs a cast and you will have a Base object
    You need Base* obj = Derived *objD; // and this is ok, virtual mechanism works with this

  2. The following 2 users say thank you to Zlatomir for this useful post:

    Cruz (30th May 2010), zoz (30th May 2010)

  3. #2
    Join Date
    Jan 2009
    Location
    Germany
    Posts
    387
    Thanks
    101
    Thanked 15 Times in 15 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: inheritence and virtual

    Thank you for the clarification!

  4. #3
    Join Date
    May 2010
    Location
    Romania
    Posts
    1,021
    Thanks
    62
    Thanked 260 Times in 246 Posts
    Qt products
    Qt5
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: inheritence and virtual

    Your welcome, careful the last two line isn't c++ code, i said it in c++ style, just to make an example.

    And for your Base class write a destructor and declare it virtual (so the objects get destroyed properly no mater what object the Base pointer points to)

Similar Threads

  1. Virtual Keyboard
    By NoRulez in forum Qt Programming
    Replies: 9
    Last Post: 5th August 2010, 07:02
  2. QGraphicsItem inheritence
    By bajarangi in forum Newbie
    Replies: 4
    Last Post: 12th August 2009, 00:45
  3. Virtual Keyboard?
    By augusbas in forum Qt for Embedded and Mobile
    Replies: 3
    Last Post: 14th July 2009, 08:55
  4. Virtual FB problem
    By nrabara in forum Newbie
    Replies: 0
    Last Post: 2nd October 2008, 06:05
  5. why triggerUpdate() is not virtual?
    By gadnio in forum Qt Programming
    Replies: 3
    Last Post: 12th January 2006, 15:05

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
  •  
Qt is a trademark of The Qt Company.