Results 1 to 3 of 3

Thread: Error creating subclasses

  1. #1
    Join Date
    May 2010
    Posts
    53
    Thanks
    2
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Error creating subclasses

    Howdy, I think my problem is more of an issue with my understanding of C++ then of Qt, but I'm using Qt so I'll post my question here.

    A little background on the problem... What I am try to do is implement a surface matching algorithm which can be trained on any 3D surface mesh. To train the algorithm a 2D histogram is generated for each vertex on the surface mesh and stored in a database. Surface matching is then performed by taking a new 3D surface mesh of the same object, randomly selecting a few vertices, calculating the 2D histogram for those vertices, and then comparing them to the 2D histograms that are stored in the database.

    What I would like to do is setup a core class that contains all the methods that are required in both the training and matching phases, ie. calculating a 2D histogram, and then subclass that core class with a training and matching class. First off, is this the general approach I should be taking?

    So I generated a class called siCore which works fine

    Qt Code:
    1. class siCore :public QThread
    2. {
    3. Q_OBJECT
    4. public:
    5. friend class MainWindow;
    6. siCore(MainWindow *gui);
    7. void run();
    8.  
    9. signals:
    10. void updateMainThreadStatus(QString statusLog);
    11. void updateMainThreadProgress(int progValue);
    12.  
    13. MainWindow *appWindow;
    14. };
    To copy to clipboard, switch view to plain text mode 

    I then generated class called siTrainer that inherits from siCore


    Qt Code:
    1. #include "sicore.h"
    2.  
    3. class siTrainer : public siCore
    4. {
    5.  
    6. public:
    7. siTrainer();
    8.  
    9. };
    To copy to clipboard, switch view to plain text mode 

    but when I compile this simple example I get the following error:
    'siCore' : no appropriate default constructor available - sitrainer.cpp
    I'm sure it is something simple, but what am I doing wrong here?

  2. #2
    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: Error creating subclasses

    Define a constructor with no arguments...
    And don't forget the class destructor, and make it virtual (for all base classes), like this:
    Qt Code:
    1. class siCore {
    2. public:
    3. siCore(){...}
    4. //...
    5. virtual ~siCore(){//... actual cleaning of dynamic allocated resources
    6. }
    7. };
    To copy to clipboard, switch view to plain text mode 

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

    agerlach (26th May 2010)

  4. #3
    Join Date
    May 2010
    Posts
    53
    Thanks
    2
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Error creating subclasses

    Thanks, I knew it would be simple!

Similar Threads

  1. Why slots in QThread subclasses are unsafe?
    By AlphaWolf in forum Qt Programming
    Replies: 8
    Last Post: 30th May 2010, 15:39
  2. declaring subclasses in C++
    By Paat in forum Newbie
    Replies: 4
    Last Post: 23rd October 2009, 08:40
  3. Linking Error when Creating DLL with Visual Studio
    By stretchtiberius in forum Qt Programming
    Replies: 6
    Last Post: 10th February 2009, 19:31
  4. create a Class inherits from two QObject subclasses
    By sabeesh in forum Qt Programming
    Replies: 17
    Last Post: 31st December 2007, 12:04
  5. Compilation error creating a project on QT4.0.1??
    By darpan in forum Qt Programming
    Replies: 6
    Last Post: 8th March 2006, 08:16

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.