User forums > General (but related to Code::Blocks)
Tutorial : How to configure Code Blocks to use it to develop Qt apps.
(1/1)
D-POWER:
Hello folks ,
First of all I want to thank the Code Blocks team for their valuable effort , so thank you for making code blocks a great IDE :) .
You probably know that there is a template for making Qt applications in Code Blocks but unfortunately errors of the type "Undefined reference to vtable" or something like that are generated when you use custom slots , this bothered me a little bit since I've been using CB for about 4 years and I'm very familiar with it , so I decided to make my own "solution".
Anyway , here is how I fixed the problem :
After opening CB , go to Tools -> Configure Tools then click at Add , choose a name for your new tool I simply called it MOC , specify the absolute path to moc.exe . Now the hardest part , in Parameters put the following line :
--- Code: ---${ACTIVE_EDITOR_FILENAME} -o moc_${ACTIVE_EDITOR_STEM}.cpp
--- End code ---
ACTION_EDITOR_FILENAME is a macro that contains the file name of the currently active file and ACTIVE_EDITOR_STEM contains the same file name but without file extension.
Finally , in the 'Working directory' field , put ${PROJECT_DIR} and click Ok.
Now that our newly created tool is installed , how are we going to use it ?
Well , just create your Qt project using the template shipped with CB , as usual , now let's say you have a class called MyClass that contains custom slots , open MyClass.h then run the tool this will generate something like moc_MyClass.cpp , include it into MyClass.cpp and the work is done :) .
I hope this little tutorial is useful .
Thank you for reading.
D-POWER
mictyd:
Hey!
Your solution is really useful and, thanks! Unfortunately, using this tool can be bit annoying, maybe have you got any idea how to do it automatically? There is "pre/post build steps" tab in "build options", is there any way to use MOC (or however this tool we called) right before building without any user's interaction?
Regards,
Michał
rubypdf:
Why not use QtCreator to develop QT apps?
Navigation
[0] Message Index
Go to full version