Hello,

I solved a problem that troubled me for a while and now I am interested in getting more insight into what has been happening here..

I have a custom data type that I want to store as a value in QMap.
Qt Code:
  1. QMap<uint, CustomType>
To copy to clipboard, switch view to plain text mode 

My CustomType looks like:

Qt Code:
  1. class CustomType
  2. {
  3. public:
  4. CustomType() { m_objectRef = nullptr; m_slotName = nullptr; }
  5. CustomType(QObject* obj, const char* slotName) { m_objectRef = obj; m_slotName = slotName; }
  6. virtual ~CustomType() {}
  7.  
  8. // Accessors
  9. QObject* GetObjectName() { return m_objectRef; }
  10. const char* GetSlotName() { return m_slotName; }
  11.  
  12. private:
  13. QObject* m_objectRef;
  14. const char* m_slotName;
  15. };
To copy to clipboard, switch view to plain text mode 

I get a compilation error saying:
Qt Code:
  1. undefined reference to `_imp___ZTV10CustomType'
To copy to clipboard, switch view to plain text mode 

Solution:
Remove virtual keyword from the destructor.

My question:
Why can't I have a virtual destructor here?

Thank you!

Regards
Vikram