What causes this QT 4.7.3 error?

I have a program that compiles fine in OpenSuse 11.2 with QT version 4.5. However, when I compiled the same program using OpenSuse 11.4 with QT 4.7.3, I get this error message:

"This file was generated using the moc from 4.7.3. It cannot be used with the include files from this version of Qt. The moc has changed too much" 

Can someone tell me what is going on?

+6
source share
3 answers

This error occurs because you are using a project that was compiled in one version of Qt. The main reason for this is that Qt uses the moc tool, which creates glue code for processing signal slots and other things.

Moc does this by analyzing header files to find definitions like Q_OBJECT, signal :, slot :, etc.

This code is fully tied to the version of Qt that was used to create this code. In some cases, this code is completely incompatible even for the same version of the Qt library that was configured with a different set of options.

This case is true even for some changes in .pro, for example, using CONFIG + = no_keywords causes moc to generate different glue code, allowing Qt to work with other libraries, such as boost, that provide signal slot mechanisms using the same keywords as and Qt.

So, in short, whenever you need to compile a Qt project with another Qt library, make sure you do the following: 1. run: make distclean 2. run: qmake 3. run: make

This will always give you a clean build tree.

+8
source

In my case, this was because I was running qmake instead of qmake-qt4. "qmake" is apparently Qt3. I came across this on Fedora Core 16.

Why is it not "qmake-qt3" and "qmake", respectively, is outside of me.

+2
source

Why don't you create a new moc using the new version (in your case it's 4.7.3) and the corresponding header file.

  moc ****.h -o ***.moc 
0
source

Source: https://habr.com/ru/post/888399/


All Articles