QML completion for BlackBerry cascades in QtCreator
-
Heya,
I'm developing apps for BB Cascades for a month or so now using QtCreator and It's been a great experience so far. The only thing I was missing was QML completion for the Cascades components. So I "fixed" it :-P
Some quick research revealed that QtCreator actually parses qmlRegisterType() in project source code to get mapping between QML and C++ classes. So to get completion all you need to do is to run the script below from
/bbnsdk/installation/path//target_10_0_9_1673/qnx6/usr/include/bb directory.The script will generate a header file that includes all bb classes and qmlRegisterType() them. So you just need to redirect output from the script to a file and then add the header file to your QMake project. The header file does not even have to be included from anywhere (which means no slowdown during compilation). It's mere presence in .pro file is enough for QtCreator.
@
#!/bin/shfolders=
find ./ -type d
declare -a includes
declare -a registrationsfor folder in $folders
do
if [ $folder = "./" ]; then
continue
fimoduleFolder=`echo $folder | cut -c3-` module=${moduleFolder%%/*} files=`ls ${folder} | grep -E --color=never "[A-Z]." | grep -E -v --color=never "*\.h|*\.hpp"` for file in $files do includes+=("<bb/${moduleFolder}/${file}>") registrations+=("qmlRegisterType<bb::${module}::${file}>(\"bb.cascades\",1,0,\"${file}\");") done
done
echo "#ifndef QTCREATOR_CASCADES_QML_COMPLETION"
echo "#define QTCREATOR_CASCADES_QML_COMPLETION"
echo -e "\n"for include in ${includes[@]}
do
echo "#include ${include}"
doneecho -e "\n"
echo "void registerCascadesQMLTypes()"
echo "{"for registration in ${registrations[@]}
do
echo -e "\t${registration}"
done
echo "}"
echo -e "\n"
echo "#endif //QTCREATOR_CASCADES_QML_COMPLETION"
echo -e "\n"
@Hope it helps ;-)
Cheers(PS: I'm not especially good at bash, but hey, it does it's job)
Update 2013-05-08: "Fixed grep regexp":http://qt-project.org/forums/viewthread/26372/#124587, thanks to "icota":http://qt-project.org/member/127709
-
Hi,
Integrating Cascades in QtCreator is a good idea… so, my contribution: you can integrate the documentation (for C++ at least), generating a qch file with Doxygen. Here are the important parts of the Doxyfile:
@Set INPUT to the include dir of BB SDK
INPUT = /opt/bbndk/target_10_0_10_822/qnx6/usr/include/
RECURSIVE = YESOutput file, relative to the html directory (hence the ../)
QCH_FILE = ../bb.qch
This name will be displayed in QtCreator to identify the file
QHP_NAMESPACE = com.blackberry
Path to qhelpgenerator binary
QHG_LOCATION = /usr/bin/qhelpgenerator-qt4
@All other values can be left to default. Then, run doxygen, it will generate a qch file you can import in QtCreator, and…!http://enoent.fr/qtcreator-help.png(Tadaaam)!
-
Hi guys,
Thanks a lot for this, can't believe I've spent a month without finding this. There's a slight bug in Dan's script however. The dot matches any character in regexp so
@grep -E -v --color=never ".h|.hpp"`@
will inversely match any file containing 'h' and not just the header files as intended. Fixed by escaping the dot:
@files=
ls ${folder} | grep -E --color=never "[A-Z]." | grep -E -v --color=never "*\.h|*\.hpp"
@Thanks again, this is very handy!
-
Hey icota,
Nice catch! Did you have any issue to catch the mistake? Just being curious :-) -
Yeah, I was curious why S h eet and C h eckBox were missing :)
-
Oh, yeah, I didn't noticed the -v ;)
-
Since not everyone wants to or can run bash scripts I've also uploaded the resulting file here:
"completion.h":http://codexapertus.hr/completion.hSimply add it to your .pro file. It is based on version 10.1.0.1020 target.
-
[quote author="Igor Cota" date="1368022657"]Since not everyone wants to or can run bash scripts I've also uploaded the resulting file here:
"completion.h":http://codexapertus.hr/completion.hSimply add it to your .pro file. It is based on version 10.1.0.1020 target.[/quote]
Does this mean just add the header file to pro. ??Now i use 10.2. version