Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    QML completion for BlackBerry cascades in QtCreator

    Mobile and Embedded
    4
    8
    4268
    Loading More Posts
    • 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
      dvratil last edited by

      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 Reply Quote 0
      • K
        Kernald last edited by

        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 Reply Quote 0
        • I
          icota last edited by

          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 Reply Quote 0
          • K
            Kernald last edited by

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

            1 Reply Last reply Reply Quote 0
            • I
              icota last edited by

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

              1 Reply Last reply Reply Quote 0
              • K
                Kernald last edited by

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

                1 Reply Last reply Reply Quote 0
                • I
                  icota last edited by

                  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 Reply Quote 0
                  • T
                    Traxx last edited by

                    [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 Reply Quote 0
                    • First post
                      Last post