Results 1 to 6 of 6

Thread: new class wizard vs. class inheritance

  1. #1
    Join Date
    Sep 2009
    Location
    Poland, Cracow
    Posts
    34
    Thanks
    2
    Qt products
    Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default new class wizard vs. class inheritance

    Hi,

    When I'm adding new class to project in QtCreator I have an option to define its super class. Problem is that the list of classes to inherit from is limited to few Qt classes, like this:
    shot94.png

    I would like to have all classes available in workspace to be there, so when I create the class it already has virtual methods and proper constructors defined by default etc.

    Is this possible? I have QtCreator 5.0.1 under Linux.
    Last edited by wysota; 4th March 2013 at 15:22.

  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: QtCreator - new class wizard vs. class inheritance

    Quote Originally Posted by googie View Post
    When I'm adding new class to project in QtCreator I have an option to define its super class. Problem is that the list of classes to inherit from is limited to few Qt classes, like this:
    shot94.png

    I would like to have all classes available in workspace to be there, so when I create the class it already has virtual methods and proper constructors defined by default etc.
    Just type in the class name in appropriate box. The combobox is only to choose the "type" of interitance which boils down to whether the generated constructor should accept a QWidget parent, a QObject parent or no parent at all.

    Considering you're using an old version of Creator, I'd suggest to upgrade it to something less dinosaur age. And please post in the proper forum next time.
    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.


  3. #3
    Join Date
    Sep 2009
    Location
    Poland, Cracow
    Posts
    34
    Thanks
    2
    Qt products
    Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QtCreator - new class wizard vs. class inheritance

    I misinformed you. I'm using QtCreator which comes with Qt 5.0.1, the actual version of QtCreator is 2.6.2. I think it's not that old, isn't it?

    Back to the main subject - yes, I'm aware I can type any class there, but the problem is that class created with the wizard doesn't #include my super class. It does add it to inheritance chain in class definition, but the #include is missing. Also none of pure virtual methods from superclass are generated in new class, no superclass-specific constructors, etc....

    When I do it for QObject it works like expected: the copying constructor for QObject is defined, the #include for QObject is added.
    Why doesn't it work for other classes?

  4. #4
    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: QtCreator - new class wizard vs. class inheritance

    Quote Originally Posted by googie View Post
    It does add it to inheritance chain in class definition, but the #include is missing.
    So add the include.
    Also none of pure virtual methods from superclass are generated in new class, no superclass-specific constructors, etc....
    I don't see why pure virtual methods would need to be generated. A subclass of a pure virtual class can still have some of the pure virtual methods unimplemented.

    Why doesn't it work for other classes?
    Because QObject is a well known Qt class with a well defined interface. In case of your own class you can have superclass "A" defined in "sometotallyarbitraryfilename.h". If you feel something is missing in QtCreator, you can implement your own plugin for it or just fix the existing code.
    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.


  5. #5
    Join Date
    Sep 2009
    Location
    Poland, Cracow
    Posts
    34
    Thanks
    2
    Qt products
    Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QtCreator - new class wizard vs. class inheritance

    Quote Originally Posted by wysota View Post
    So add the include
    Really...? The point of using sophisticated IDE is to have it do stuff for you. Sure developer can do manually everything, but IDE's purpose is to assist, automate and simplify.

    I guess that's just not implemented - yet.

  6. #6
    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: QtCreator - new class wizard vs. class inheritance

    If I remember correctly it was implemented in the old Creator versions but was then removed for some reason. Maybe the team was receiving bug reports such as "Why does Creator include myclass.h instead of {MyClass.h,Myclass.h,myverysophisticatedclass.h}?"
    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. Replies: 1
    Last Post: 3rd December 2012, 09:57
  2. Replies: 2
    Last Post: 23rd October 2012, 09:46
  3. Inheritance of nested class
    By bibhukalyana in forum Qt Programming
    Replies: 2
    Last Post: 6th August 2011, 18:54
  4. Inheritance confusion - which class made inheritating from QObject
    By kornicameister in forum Qt Programming
    Replies: 1
    Last Post: 23rd December 2010, 09:54
  5. Replies: 2
    Last Post: 2nd December 2010, 17: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.