Q_object Error
Contents |
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of undefined reference to vtable qobject this site About Us Learn more about Stack Overflow the company Business Learn unresolved external symbol qt_metacast more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question undefined reference to vtable for class qobject x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 6.2 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up
Qt Moc File
Q_OBJECT linker error! up vote 10 down vote favorite 3 I am receiving the following linker error when I build my application. HIMyClass.obj:: error: unresolved external symbol "public: virtual struct QMetaObject const * __thiscall CHIMyClass::metaObject(void)const " (?metaObject@CHIMyClass@@UBEPBUQMetaObject@@XZ) File not found : HIMyClass.obj HIMyClass.obj:: error: unresolved external symbol "public: virtual void * __thiscall CHIMyClass::qt_metacast(char const *)" (?qt_metacast@CHIMyClass@@UAEPAXPBD@Z) File not found : HIMyClass.obj HIMyClass.obj:: error: qt_metacast char const * unresolved external symbol "public: virtual int __thiscall CHIMyClass::qt_metacall(enum QMetaObject::Call,int,void * *)" (?qt_metacall@CHIMyClass@@UAEHW4Call@QMetaObject@@HPAPAX@Z) File not found : HIMyClass.obj My class declaration is like class CHIMyClass:public QDialog { Q_OBJECT .... }; When I comment Q_OBJECT the linker error goes off (and obviously I am not able to use signals and slots). I am using Qt Creator as IDE and Qt 4.5.3. When I give Rebuild All it's definite that QMake will be called. I guess that, its the generation of moc_* files is where the problem lies. I am using Windows XP and cl as the compiler. What might be the reason behind this linker error? c++ qt qt4 linker-error qobject share|improve this question edited Jul 16 '10 at 11:33 asked Jul 16 '10 at 11:20 liaK 7,51963060 Maybe File not found : HIMyClass.obj tell us, that Qt Creator does not saw moc/obj/temp files? –mosg Jul 16 '10 at 11:39 1 Really, rerun qmake. Also, check for missing or extra "\" characters in your .pro file. –andref Jul 16 '10 at 17:22 add a comment| 11 Answers 11 active oldest votes up vote 24 down vote accept
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the company error: undefined reference to `vtable for ' Business Learn more about hiring developers or posting ads with us Stack Overflow Questions
Unresolved External Symbol Staticmetaobject
Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 6.2 million
Qt Undefined Reference To Vtable For Constructor
programmers, just like you, helping each other. Join them; it only takes a minute: Sign up Q_OBJECT throwing 'undefined reference to vtable' error [duplicate] up vote 40 down vote favorite 15 This question already has an answer http://stackoverflow.com/questions/3264259/q-object-linker-error here: Qt Linker Error: “undefined reference to vtable” 8 answers I'm using Qt Creator 2.0.1 with Qt 4.7.0 (32 bit) on Windows 7 Ultimate 32 bit. Consider the following code, which is a minimum to produce the error: class T : public QObject, public QGraphicsItem { Q_OBJECT public: T() {} QRectF boundingRect() const {return QRectF();} void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) {} }; int main() { T t; return 0; } The http://stackoverflow.com/questions/4774291/q-object-throwing-undefined-reference-to-vtable-error above code fragment causes the following linker errors: In function `T': undefined reference to `vtable for T' undefined reference to `vtable for T' In function `~T': undefined reference to `vtable for T' undefined reference to `vtable for T' If I comment out the line that contains Q_OBJECT, it compiles fine. I need signal and slots with QGraphicsItem so I need Q_OBJECT. What is wrong with the code? Thanks. c++ qt linker-error vtable share|improve this question asked Jan 23 '11 at 14:24 Donotalo 7,167145993 marked as duplicate by djf, Rubens, Phil Hannent, tjameson, John Doyle Jul 13 '13 at 19:03 This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question. add a comment| 5 Answers 5 active oldest votes up vote 71 down vote accepted It is because the unit generated by MOC isn't included in the linking process. Or maybe it isn't generated at all. The first thing I'd do is to put the class declaration in a separate header file, perhaps the build system isn't scanning implementation files. Another possibility is that the class in question once didn't belong to Qt meta object system (that is, it had no Q_OBJECT or maybe didn't inherit from QObject at all), so qmake needs to be
download a browser that supports JavaScript, https://forum.qt.io/topic/7700/solved-trouble-with-q_object-signals-slots or enable it if it's disabled (i.e. NoScript). http://www.qtcentre.org/threads/35953-errors-when-using-Q_OBJECT-and-slots Home Qt Development General and Desktop [solved] Trouble with Q_OBJECT Signals & Slots [solved] Trouble with Q_OBJECT Signals & Slots This topic has been deleted. Only users with topic management privileges can see it. undefined reference huckfinn last edited by Hello BoysNGirls, I have a problem with a dialog window which I have created. I thought I already had solved all related problems, but seems not. I have a small dialog window with a few QPushButtons and QLabels. Further undefined reference to on I created an own SLOT which I called deleteItem(): @ #pragma once #include
this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. Welcome to Qt Centre. Qt Centre is a community site devoted to programming in C++ using the Qt framework. Over 90 percent of questions asked here gets answered. If you are looking for information about Qt related issue — register and post your question. You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today! If you have any problems with the registration process or your account login, please contact us. + Reply to Thread Results 1 to 10 of 10 Thread: errors when using Q_OBJECT and slots Thread Tools Show Printable Version Subscribe to this Thread… Search Thread Advanced Search Display Linear Mode Switch to Hybrid Mode Switch to Threaded Mode 13th November 2010,00:47 #1 kja View Profile View Forum Posts View Blog Entries View Articles Novice Join Date Oct 2010 Posts 58 Thanks 26 Qt products Platforms errors when using Q_OBJECT and slots Hi, I'm new to qt programming and I'm trying to make some custom signals and slots but I keep getting errors when I try to do some simple examples. I can get this program to run by commenting out Q_OBJECT, but if I leave it in i get errors, any idea why that is? Qt Code: Switch view #include