Results 1 to 2 of 2

Thread: Inheritance confusion - which class made inheritating from QObject

  1. #1
    Join Date
    Sep 2010
    Location
    Poland
    Posts
    112
    Thanks
    8
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Maemo/MeeGo

    Default Inheritance confusion - which class made inheritating from QObject

    I have two singular classes and one set of classes which inherit from one of these two mentioned before.

    So I have
    (partly) abstract class A(public common methods and some variables), and abstract class B (includes only four methods pure virtual)
    those two are not linked in any way (and for now none of them inherits QObject)
    going on to the set
    these classes inherit A and B mostly, but two of them does not require it.

    I am familiar that I can not make multiple inheritance from QObject... so I would like to ask where to put "single" inheritance statement and all additional stuff such as appropriate macros and so on ?
    For now all classes from set includes inheritance from QObject... but maybe it would be better to push it (QObject and all related stuff) to class A, because every class in set uses it, except to class B
    My schedule makes my cry
    My works makes my laugh
    My life makes... oh...no....

  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: Inheritance confusion - which class made inheritating from QObject

    Do I understand correctly that you have two classes that inherit just A or just B and a bunch of classes that inherit both A and B? If so then if you don't need QObject at the level of A or B then if you need QObject at the level of those subclasses then inherit QObject in your bottom-most class. Just remember QObject has to go first.

    Qt Code:
    1. class MyClass: public QObject, public A, public B {
    2. Q_OBJECT
    3. //...
    4. };
    To copy to clipboard, switch view to plain text mode 
    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. Determine Class Type of QObject Parent
    By photo_tom in forum Qt Programming
    Replies: 2
    Last Post: 12th May 2010, 17:42
  2. Multiple inheritance with QObject
    By victor.fernandez in forum Qt Programming
    Replies: 1
    Last Post: 22nd April 2010, 16:40
  3. Class Confusion
    By Petr_Kropotkin in forum Newbie
    Replies: 5
    Last Post: 23rd January 2010, 15:23
  4. Possibly an inheritance problem with QObject?
    By chadkeck in forum Qt Programming
    Replies: 8
    Last Post: 5th November 2008, 01:26
  5. subclassing/inheritance QObject problem
    By cbeall1 in forum Qt Programming
    Replies: 12
    Last Post: 13th February 2006, 17:49

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.