Results 1 to 2 of 2

Thread: Dynamic plugin: accessing parent's methods

  1. #1
    Join Date
    Feb 2008
    Posts
    153
    Thanks
    40
    Thanked 8 Times in 5 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Dynamic plugin: accessing parent's methods

    Hi,

    So if I have a custom QPlugin, is it somehow possible to access its parent's methods by casting the parent() property to the main class? Im getting problems because when I include the parent header file in the plugin, they are not virtual so moc complains... I.e. Undefined references. Thanks!
    [WIKI]Building Qt on Windows CE[/WIKI]

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Dynamic plugin: accessing parent's methods

    It's highly against OOP principles to do such a thing. If you rely that the parent is always of class X then when setting a parent, accept a pointer to X and store it in a variable to X. Then no cast will be required and nobody will use your class in a way that could break it (i.e. by passing a parent of different class).
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


Similar Threads

  1. Adding Library Methods - Static Vs Dynamic
    By waynew in forum Qt Programming
    Replies: 1
    Last Post: 15th January 2010, 16:16
  2. Dynamic widget plugin
    By bunjee in forum Qt Programming
    Replies: 1
    Last Post: 30th April 2009, 18:26
  3. Accessing QMainWindow methods
    By vieraci in forum Qt Programming
    Replies: 2
    Last Post: 21st April 2009, 08:38
  4. Problem building dynamic plugin
    By javd in forum Qt Programming
    Replies: 3
    Last Post: 6th April 2009, 18:02
  5. accessing gui elements from parent
    By chemstar in forum Qt Programming
    Replies: 3
    Last Post: 21st May 2006, 11:22

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.