Thread: Subclassing

  1. #1
    Registered User
    Join Date
    Dec 2001
    Posts
    2

    Subclassing

    I'm working on a small gui project and I needed to subclass a form. Everything looks ok but when I go and compile I'm getting the following error
    In function `AMainWindow::AMainWindow(QWidget *, char const *, unsigned int)':
    .obj/amainwindow.o(.text+0xb1): undefined reference to `AWorkspace virtual table'

    The subclass is called AWorkspace. Any pointers (no pun intended) in the right direction would be great.

    Thanks

  2. #2
    Registered User
    Join Date
    Dec 2001
    Posts
    421
    we're going to need more info than that... paste some code or give a little more detail.

    looks like something to do with not specifying the body of a virtual function..
    that's just a guess though.
    Quidquid latine dictum sit, altum sonatur.
    Whatever is said in Latin sounds profound.

  3. #3
    Registered User
    Join Date
    Dec 2001
    Posts
    2
    #ifndef AWORKSPACE_H
    #define AWORKSPACE_H

    #include <qworkspace.h>

    class AWorkspace : public QWorkspace
    {
    Q_OBJECT
    public:
    AWorkspace(QWidget *parent = 0, const char *name = 0) : QWorkspace(parent,name) {}

    ~AWorkspace() {}
    protected:
    void childEvent(QChildEvent *e);
    };

    #endif //AWORKSPACE_H

    This is all that there is. The errors that I was talking about simply came when I tried to create an instance of this class. The childEvent function is virtual in the base class. I also tried this with just the constructor and destructor and was running into the same issues.

  4. #4
    Registered User JasonLikesJava's Avatar
    Join Date
    Mar 2002
    Posts
    175
    I'm getting the same error.... Everything was fine until I added the Q_OBJECT macro. I can do everything with my class when I take out the Q_OBJECT macro only I no longer have signals and slots.
    Last edited by JasonLikesJava; 05-30-2002 at 12:09 PM.
    OS: Linux Mandrake 9.0
    Compiler: gcc-3.2
    Languages: C, C++, Java

    If you go flying back through time and you see somebody else flying forward into the future, it's probably best to avoid eye contact.

  5. #5
    Registered User JasonLikesJava's Avatar
    Join Date
    Mar 2002
    Posts
    175
    Hmm... I got my class working, although I'm not even sure what I changed exactly. Try removing all compiled objects and then compile it again including <qwidget.h>
    OS: Linux Mandrake 9.0
    Compiler: gcc-3.2
    Languages: C, C++, Java

    If you go flying back through time and you see somebody else flying forward into the future, it's probably best to avoid eye contact.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. I got subclassing to work, but....
    By cl2606 in forum Windows Programming
    Replies: 2
    Last Post: 07-06-2008, 03:28 PM
  2. Subclassing
    By alex0751 in forum C++ Programming
    Replies: 2
    Last Post: 01-21-2008, 06:39 PM
  3. Subclassing
    By Mithoric in forum Windows Programming
    Replies: 5
    Last Post: 11-22-2003, 05:30 PM
  4. Subclassing Problem
    By Thunder in forum Windows Programming
    Replies: 4
    Last Post: 10-22-2003, 03:49 PM
  5. Subclassing a listbox and the speed of the postal service
    By SMurf in forum Windows Programming
    Replies: 3
    Last Post: 09-14-2002, 07:25 PM