Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. QML completion for BlackBerry cascades in QtCreator
Forum Updated to NodeBB v4.3 + New Features

QML completion for BlackBerry cascades in QtCreator

Scheduled Pinned Locked Moved Mobile and Embedded
8 Posts 4 Posters 4.7k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    dvratil
    wrote on 3 Apr 2013, 10:15 last edited by
    #1

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

    folders=find ./ -type d

    declare -a includes
    declare -a registrations

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

        moduleFolder=`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}"
    done

    echo -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

    Collecting data is only the first step toward wisdom, but sharing data is the first step toward the community.

    1 Reply Last reply
    0
    • K Offline
      K Offline
      Kernald
      wrote on 28 Apr 2013, 16:23 last edited by
      #2

      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 = YES

      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)!

      1 Reply Last reply
      0
      • I Offline
        I Offline
        icota
        wrote on 8 May 2013, 13:33 last edited by
        #3

        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!

        1 Reply Last reply
        0
        • K Offline
          K Offline
          Kernald
          wrote on 8 May 2013, 13:40 last edited by
          #4

          Hey icota,
          Nice catch! Did you have any issue to catch the mistake? Just being curious :-)

          1 Reply Last reply
          0
          • I Offline
            I Offline
            icota
            wrote on 8 May 2013, 13:49 last edited by
            #5

            Yeah, I was curious why S h eet and C h eckBox were missing :)

            1 Reply Last reply
            0
            • K Offline
              K Offline
              Kernald
              wrote on 8 May 2013, 13:52 last edited by
              #6

              Oh, yeah, I didn't noticed the -v ;)

              1 Reply Last reply
              0
              • I Offline
                I Offline
                icota
                wrote on 8 May 2013, 14:17 last edited by
                #7

                Since not everyone wants to or can run bash scripts I've also uploaded the resulting file here:
                "completion.h":http://codexapertus.hr/completion.h

                Simply add it to your .pro file. It is based on version 10.1.0.1020 target.

                1 Reply Last reply
                0
                • T Offline
                  T Offline
                  Traxx
                  wrote on 17 Nov 2014, 15:07 last edited by
                  #8

                  [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.h

                  Simply 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

                  1 Reply Last reply
                  0

                  • Login

                  • Login or register to search.
                  • First post
                    Last post
                  0
                  • Categories
                  • Recent
                  • Tags
                  • Popular
                  • Users
                  • Groups
                  • Search
                  • Get Qt Extensions
                  • Unsolved