简体   繁体   中英

Qt Q_OBJECT class compilation

What is needed for errorfree compilation when adding a class that is flagged as

Q_OBJECT

? Should one run qmake file ?

New classes are written in .h .cpp files that are already added in .pro .pri files.

My metaphysics questions are

1/ is qmke_all.bat run and rebuild all enough to have Qt dependencies cleared up ? if not, what is procedure ?

2/ why is this procedure needed, what happens?

3/ what are .pro .pri for ? are both of them here for 'mapping' with qt ? should i change anything to them when adding classes but no .h .cpp files ?

I am with VS2010

thanks

If you've added Q_OBJECT to a self-defined class you need to run qmake prior to compilation, otherwise it won't generated the meta code needed for it.

1) Not sure what you mean here, sorry.

2) Or here.

3) The .pro and .pri are essentially directives files for qmake, much the same way Makefiles work for make. There's obvious differences, but you're not far off when you say they're for mapping, they're there to tell qmake how to generate the necessary compilation files. When you're adding new classes if they've not been auto-added then you need to add both the .cpp & .h files.

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