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.


    folders=find ./ -type d

    declare -a includes
    declare -a registrations

    for folder in $folders
    if [ $folder = "./" ]; then

        moduleFolder=`echo $folder | cut -c3-`
        files=`ls ${folder} | grep -E --color=never "[A-Z]." | grep -E -v --color=never "*\.h|*\.hpp"`
        for file in $files


    echo -e "\n"

    for include in ${includes[@]}
    echo "#include ${include}"

    echo -e "\n"
    echo "void registerCascadesQMLTypes()"
    echo "{"

    for registration in ${registrations[@]}
    echo -e "\t${registration}"
    echo "}"
    echo -e "\n"
    echo -e "\n"

    Hope it helps ;-)

    (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/

    Output 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:

    Simply add it to your .pro file. It is based on version 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:

    Simply add it to your .pro file. It is based on version target.[/quote]

    Does this mean just add the header file to pro. ??Now i use 10.2. version

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.