Fail to import QML module using CMake - c++

I'm currently building a minimalist app following this CMake architecture:
-root
--QmlModule
---Component1.qml
---Component2.qml
--App1
---main.cpp
---main.qml
--App2
---main.cpp
---main.qml
I use "qt6_add_qml_module" to create a QML module at "QmlModule" level as a STATIC library.
qt_add_library(myComponentTarget STATIC)
qt6_add_qml_module(myComponentTarget
URI QmlModule
VERSION 1.0
QML_FILES
Component1.qml
Component2.qml
RESOURCES
logo.png)
Then, at App1 (and App2) level, a link to the module is done using "target_link_libraries". "qt6_add_qml_module" does some work behind the scenes in order to expose the module trough an automatically generated plugin named "your_component_URIplugin". More details about this here.
add_executable(App1Exe
main.cpp)
qt6_add_qml_module(App1Exe
URI App1
VERSION 1.0
QML_FILES
main.qml)
target_link_libraries(App1Exe
PRIVATE
myComponentURIplugin)
At Root level, I overload QML_IMPORT_PATH in order to link to the build folder and add all subdirectories.
set(QML_IMPORT_PATH ${CMAKE_CURRENT_SOURCE_DIR}/qmlModule)
add_subdirectory(QmlModule)
add_subdirectory(App1)
add_subdirectory(App2)
I run CMake without any errors, and open App1/main.qml file.
On my import QmlModule, the module can't be found:
module "lupinComponentsplugin" is not installed
How to make my module visible from my Apps ?
What step am I missing ?

I'm currently doing something similar.
I have created a demo app where I import modules. The modules provide QML and C++ items to the main app. Check the comments in the CMAKE files to find out how this works.
Here is the link:
https://gitlab.com/basic53/DemoApp
Feel free to comment on this.
Another tip: If qt_add_qml_module is not working properly, sometimes it is necessary to remove the whole build folder and update the QML code model. You can check the generated files to see, if your plugin has been created with all its types.

CMake itself was fine, this was a runtime error and not a link error.
This issue was raised because the QQmlApplicationEngine wasn't finding path towards my module's QMLDIR.
In the end, the only thing missing was an additional import path ":/" in QQmlEngine:
QQmlApplicationEngine engine;
engine.addImportPath(":/");

Related

Unable to import sikuli library in RIDE

I have to write automation scripts using python and Robot framework. I have installed python, Robotframework, RIDE, wxpython. I have installed sikuli library but when I import it in my project, library is not imported. I have tried 'Import Library Spec XML'. My question is from where do I import this .xml or how do I create it?
You might need to declare the Pythonpath on RIDE preferences (Tools>Preferences>Importing), you must add there your libraries location, it helped me with suds library.
I have added there:
C:\Python27\lib\site-packages\robot\libraries
(This could be little different for you if you have installed your python at different location)
Edit:
This could be an issue on the way you are trying to import your library, or you need to download a specific sikuli library that work with robot.
Please check then if you are loading your library like this:
*** Settings ***
Library SikuliLibrary
got it from: https://github.com/rainmanwy/robotframework-SikuliLibrary
First check whether Sikuli is installed in python directory's \Lib\site-packages.
Robot test should contain as below:
* Settings *
Documentation Sikuli Library Demo
Library SikuliLibrary mode=NEW
* Test Cases *
Sample_Sikuli_Test
blabh blabh etc

WebStorm with Babel not working with import statements

I'm using WebStorm 2017.1.3, although also tried with latest EAP, and i can't get import from statement to work. I just keep getting the following error:
import Utils from './utils'
^^^^^^
SyntaxError: Unexpected token import
In my packages.json i have babel-cli, babel-preset-env and babel-preset-es2015 defined. I have followed various blog posts and videos but still get same error.
ES6 is enabled in settings and i tried adding Babel file watch as per documentation but nothing seems to work. This feels like it should be a lot easier and just work, so i must be missing a important part of the jigsaw.
Does anyone have a working step by step, from fresh project, how to guide in configuring webstorm to work with import ?
Some places say use file watch, others say just to change project configuration interpreter to use babel-node. Other say must use Gulp... very confusing.
Thank you.
fLo
To make things clear: this is not about configuring WebStorm, error comes from Node.js interpreter that runs your code. Node.js still doesn't support ES6 modules natively (actually, no JavaScript runtime currently supports them - ECMAScript does not define a "Loader" specification which determines how Modules are inserted into the runtime. The Loader spec is being defined by WHATWG, but is not yet finalized). So, to get ES6 imports/exports accepted, you need using transpilers. Current industry standard is Babel
The most simple way to make it work is the following:
install babel in your project using npm install --save-dev babel-cli babel-preset-env
create a .babelrc file in project root dir:
{ "presets": ["env"] }
in your Node.js Run configuration, pass -r babel-register to Node:
With this configuration, your code will be transpiled on-the-fly by Babel, no file watchers, etc. are needed

Ember Cli - Transpiling vendor ES6 dependency in ember-cli-build?

I'm writing an Ember.js application using Ember Cli, and I want to include a non-bower dependency - basically a dependency from my vendor folder.
The instructions on doing so is telling me to add the following line into my ember-cli-build.js file:
app.import('vendor/dependency-to-include.js');
That would work fine with a normal ES5 flavored dependency, but what if I want to add a dependency written in ES6?
Right now it just delivers it to the browser untouched, which produces an error like:
Uncaught SyntaxError: Unexpected reserved word
because my ES6 flavored dependency uses the following syntax:
import Util from './util
I'm guessing that I need to tell ember-cli-build to transpile this particular dependency before passing it on to the browser, but how do I go about doing that?
Thanks
For transpiling imported dependencies you need to run the imported file(s) through the broccoli addon broccoli-babel-transpiler. For a basic example, checkout this file: https://github.com/thefrontside/ember-impagination/blob/2fa38d26ef1b27a3db7df109faa872db243e5e4c/index.js. You can adapt this addon to an in-repo addon for your project.
See this link for the background discussion and #rwjblue and #cowboyd on the actual fix: https://github.com/ember-cli/ember-cli/issues/2949
Are you currently including Babel within your project? I would have thought that it checks your vendor directory the same as it does everything else and converts the ES6 code to ES5.
The other option would be to just convert the file to ES5 manually whenever you need to include a vendor file with ES6 syntax. Not necessarily ideal, but if it's a static file then it's something you'll need to do once and then forget about.

qmlscene replace c++ module

I have a qml import statment that is something like
import com.my.namespace.logic
and this is from a c++ registered class
qmlRegisterType<ApplicationController>("com.my.namespace.logic", 1, 0, "ApplicationController");
Now I want to be able to use qmlscene to run this with special testing logic. So I made a folder structure like
▾ testingdata/
▾ com/
▾ my/
▾ namespace/
ApplicationController.qml
LoginController.qml
MasterController.qml
qmldir
I made sure that my qmldir's first line was
module logic
Then tried to run
qmlscene -I testingdata main.qml
but it will always complain that my namespace isn't registered. Has anyone tried to do this?
What I did is I made another project that includes all the headers and source plus some extended classes so that it could run as a separate executable that doesn't connect to any online services.

Codeigniter Tank_Auth used as a HMVC module along with the Template library

I've successfully configured and run HMVC on my clean install of Codeigniter 2.1.0
Then I've included Template library. It consist of only 3 files: /system/library/Template.php, /application/config/template.php and finally, template file itself (somewhere in /views directory).
I've tested template library while loading one of my created modules. I had to go to /system/library/Template.php to correct paths so they point to my module/views instead of default CI's ones.
Then I tested and it seemed just fine.
The third step is to include Tank_Auth authentication library. I want it to reside in module as well (/modules/auth). This module should have the same directory structure just like a regular app directory does (config, controllers, language, libraries, models, views, etc.) so I can copy Tank_Auth's files to Auth module's respective directories.
Basically, I have already done that copy part. But now when I try to run http://adresar.local/auth/auth/login I get
An Error Was Encountered
Unable to load the requested file: auth/login.php
I've also tried changing
class Auth extends CI_Controller
to
class Auth extends MX_Controller
but to no avail.
If anyone can throw in some useful advice I will appreciate it a lot.