简体   繁体   中英

Qt compiling error 1

When i try to compile my program i get this

error: [tmp/moc/debug_shared/moc_window.cpp] Error 1

I have a class called Window. when I comment the Q_OBJECT line it compiles, but I can't use any slots.

class Window : public QWidget {
  // Q_OBJECT
public:
  Window();
public slots:
  void update();
};

I have QT 4.7 installed.

Any Idea why it doesn't compile when I uncomment the Q_OBJECT line? Thanks for any help.

You have a slot so you must have the Q_OBJECT macro, after adding this do a clean build. And in case of an error, post the whole error log not the last line.

maybe something is wrong with Moc paths... make sure that you have write rights in folder you use for moc-ing qt headers. ( tmp/moc/debug_shared/ ). And I don't know this extractly for linux, but on windows directory where you generating moc files must exist.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM