Category Archives: Programming

(If you are searching for a solution to the above error then look at the last few paragraphs of this post, the first part is just me babbling about why I got my self into a situation where I had the above error).

So, I had an Qt5 application that used qml for the main interface, that worked fine. I then wanted to extend the application with some content that was dynamically loaded from a website, this website contained some html5 with embedded JavaScript that needed to communicate with the Qt5 application, and the application needed to call into the JavaScript.

It should be straight forward, I first made the Android version, using the Android Webkit browser, it worked out of the box, binding into the Java world with JNI, and then into the WebKit browser, but when it came to using the WebKit that came with Qt, ohh, my.. that was when the trouble began…. of cause it was my lack of knowlegde and not the framework that were the issue.

First I tried with a qml WebView controller, that loaded the page fine, but when it came to the JS integration, I couldn’t figure it out, I then found that the QML WebView, and the QWebView is something completely unrelated (more or less) where the QML WebView is very limited (unless you go to the private interface) the QWebView is much more reach and allows the integration with JS.

There are many examples on the web on how to use the QWebView class, they all went something like this:

Now, what should “parent” be??? – I had no clue, I tried many different things, including leaving it blank, but each time the code crashed when executed… I finally left it blank, but the code was still crashing with the message that is the title of this post.

I then tried to dig into what a QApplication was, and presto… – the issue was not related to the way I launched the webpage, it was in how I made the qml app run. I originally had code like:

Well, I’ve been trying different things out at work the last week in order to make some small tests and evaluating different design ideas – I can’t reveal what it’s all about yet, except I could mention some buzz words that doesn’t really say anything (scalability, cross-X, open source, market killer, etc. etc. etc. some of these might be true, some might be wishes and some might just be pure imagination).

Anyway as part of this I have been writing a number of small Android applications – and guess what, I learned the hard way that you can’t use _ (Underscores) or numbers as the first character like systems.mikek.oneforall is ok, but systems.mikek.1forall isn’t – which might make sense, as numbers are not allowed as the first character in identifiers in many languages (even they are fine for URL’s) – but I was a bit more surprised that prefixing the number with _ wasn’t allowed either – so no systems.mikek._1forall either… lesson learned 🙂

^__^
Mike

btw. I don’t know if this is just for Android, or generic for Java (actually I only tried it in an app made in the Qt5 framework for Android).

Apache Cordova is a tool/library/… for writing cross platform (mobile) applications. With Cordova you write the code in HTML5, CSS and JS like you would on a homepage, just packed into an application that can run on many different platforms.

But Cordova is more than just that, it also has a number of plug-ins that makes it possible to access systems on the platforms that a normal web application can’t access. It is even possible to make your own plug-ins. The plug-ins are typically written in the native language for the platform, like Java for Android, C# for Windows Phone etc.

Unfortunately the “official” Cordova documentation for writing plug-ins are…hmm…aeee… let’s just say, I couldn’t figure it out, but thanks to Google I found this blog post that describes how to write plug-ins in Java for Android.