Monthly Archives: April 2017

Leap Motion Controller, Great Hardware in Search of Great Software

By now, we all know what the future will be like; movies and TV shows have described it in detail. We know about the flying cars (thank you, “Blade Runner”), holograms (thank you, “Star Trek”) and robot butlers (thank you, “Jetsons”).

The Leap Motion Controller is a solution in search of a problem: its hardware is simple, but it needs a killer app.

So when will we really get those technologies? Probably on the 11th of “Don’t hold your breath.”

There is, however, one exception. As of this week, you can buy your own little piece of “Minority Report” and “Iron Man”: controlling your computer by making hand motions in the air.

The Internet has been buzzing about the much-delayed Leap Motion Controller ($80) since its first public demonstrations over a year ago. Imagine controlling on-screen objects just by reaching into empty space, just like Tom Cruise! Imagine gesture recognition just like Microsoft’s Kinect game controller, but on a much smaller, more precise scale! Imagine the future, plugged into a USB jack on the Mac or Windows PC you own today!

The Leap Motion sensor is beautiful, tiny and self-contained. If Wrigley’s ever comes out with a Juicy Fruit Designer Pack, it might look like this: a sleek, glass-and-aluminum slab (1.2 by 3 by 0.5 inches), with nonskid rubber on the bottom. A single USB cable (both a long one and a short one come in the box) stretches away to your computer; a light comes on when it’s working.

(Please note that Leap Motion has nothing to do with Leap Pad, the children’s toy. That gadget is educational in a completely different way.)

If you have a desktop computer, you put the sensor between your screen and keyboard. If it’s a laptop, you park it on the desk just in front of the keyboard. Soon, Leap says, you’ll be able to buy a PC from H.P. or Asus that has the sensor built right in.You download the Leap software, and presto: a somewhat buggy tutorial instructs you to insert your hands into the space — an invisible two-foot cube — that’s monitored by the Leap’s cameras and infrared sensors.

This device is like the Kinect in that it recognizes body parts in space. But not only is the Leap far smaller and less expensive, it’s also far more precise. According to the company, it can detect the precise positions of all 10 of your fingers simultaneously, with a spatial accuracy to a 100th of a millimeter — 200 times as accurate as the Kinect.

And remember, the Leap adds gesture recognition not to your TV, but to your computer. A machine that can run millions of different programs for all different purposes. Games, sure, but also office work. Creative work. Communication. Entertainment. Surely this little wonder is a very big deal.

Unfortunately, it’s not. The Leap’s hardware may be simple, attractive and coherent — but its software is scattershot, inconsistent and frustrating.

The first crushing disappointment is that no software recognizes your hand motions unless it’s been specially written, or adapted, for use by the Leap.

There are 75 such apps already on the Leap’s app store, Airspace; some are free, some cost a few dollars. Not all work on both Mac and Windows.

Most are games. In the best of them, you control the action in 3-D space, just as with the Kinect but without having to stand up. For example, Boom Ball ($5) is the classic Breakout game, where you try to knock out bricks by bouncing a ball against them — but your paddle is attached to your finger in vertical space.

In Disney’s clever Sugar Rush ($2), a spin off from the “Wreck-It Ralph” movie, you bake yourself a racing car shaped like a wedge of cake, and then steer it by holding both sides of an invisible steering wheel. When you play Dropchord ($3), you hold two index fingers out in space; you’re defining a line between them that you use to slice dots and avoid X’s. Cut the Rope is here, too (free).

There are some interesting music-making programs, which makes sense, since hand motions are generally associated with playing instruments. Air Harp ($1) is just what it sounds like. Chordion Conductor is a sweet-sounding arpeggiator (generates music from chords you select).

A few simple educational apps are available, like Molecules (rotate molecules on the screen; free), Cyber Science 3D (pull apart a skull; free) and Frog Dissection (you guessed it; $4).

Yahoo! to Live Stream Video of Second Quarter 2013 Earnings on Yahoo! Finance

Yahoo! Inc. (YHOO) will live stream a video broadcast of the company’s second quarter financial results on Tuesday, July 16, 2013, at 2 p.m. Pacific/5 p.m. Eastern. The live stream will be broadcast from Yahoo!’s Sunnyvale studio and will be available exclusively on Yahoo! Finance at finance.yahoo.com.

The video will be archived after the event athttp://investor.yahoo.net and will be available for 90 days following the broadcast.

About Yahoo!

Yahoo! is focused on making the world’s daily habits inspiring and entertaining. By creating highly personalized experiences for our users, we keep people connected to what matters most to them, across devices and around the world. In turn, we create value for advertisers by connecting them with the audiences that build their businesses. Yahoo! is headquartered in Sunnyvale, Calif., and has offices located throughout the Americas, Asia Pacific (APAC) and the Europe, Middle East and Africa (EMEA) regions. For more information, visit the pressroom (pressroom.yahoo.net) or the company’s blog (yahoo.tumblr.com).

Yahoo! is the trademark and/or registered trademark of Yahoo! Inc.

Google Open Streaming TV Service

California: Google is rumored to be opening for Google TV streaming service. The tech giant is said to be developing a streaming service similar to cable TV services, such as Hulu or Netflix.
Wall Street Journal reported on Tuesday, July 16, 2013, according to sources who declined to be named. The source revealed that Google has approached several media companies to discuss licensing and television program content. Google wants to provide more services to Google TV via channels such as television package, but by using a broadband connection.
Google TV audience of streaming content will not require registration and subscription requirements as well as cable television service. Google TV so users will not be charged monthly. Google TV is not much different from the Apple TV. But the Apple TV first implement streaming TV service.
Google seems to need to fight hard to make it happen because just like the Apple TV earlier, the problem of security issues and also the reluctance of media companies to cooperate with Web TV newcomers a big challenge.

Yahoo Open Start Request Username ‘Beautiful’ is Not Active Again

Since last month it was announced that Yahoo will delete the Yahoo! username or ID is no longer active, many people are waiting for the arrival of this. Because, mostly inactive username is precisely deter others who want to use the name. Now, according to the announcement last month, Yahoo began to open up opportunities for those who want to get the username ‘pretty’.
Users who want to get the username ‘beautiful’ can not directly get the name. They should write the desired username in advance through a form benama Yahoo! Wish List. Yahoo provides five options that could be asked. If the first choice is not available, then the choice of the required reserves would then look for. Yahoo will provide notice of the availability of username via email in mid-August 2013.
“To get Yahoo! username you’ve always wanted, we set up a page where you can ask five top choices. If your first choice is not available, we will try to find other options of backup you have the content. In mid-August, you will receive email containing the username where available, as well as links to mengklaimnnya for 48 hours. Quite so, and it is yours, “wrote Dylan Casey, Senior Director, Platform Yahoo via its official blog.

Take advantage of travelers Google Google Maps

Jakarta – Indonesia invites the travelers Google using Google Maps on your phone. Rudy Ramawy, Country Head of Google Indonesia, said Google Maps on your phone makes it easy to plan the travelers a safe and comfortable journey.
“Some of it’s ease of search as the most convenient path to the destination,” said Rudy. “You can also find important information regarding the need for travel. Example, the nearest gas station or ATM.”
The travelers can also record all findings during the course of the digital device. “So, when I travel the same route, you can easily find the places you’ve visited,” Rudy explained.
When stuck in traffic, Google Maps users can find an alternative way. This online map applications presents several alternative options that can help road users avoid severe congestion at homecoming.
Google Maps to apply different color lines for different traffic conditions. For example, if there is a congested line, the red line. Yellow to crowded conditions and solid edging, while green for road conditions smoothly.
In addition, Google Maps provides information on the long journey from the user’s location to the destination or hometown. Google Maps even provide mileage information is based on the means of transportation used. For example, driving alone, walking, or using public transportation. Google Maps also provides information public transport fares.
With features and conveniences that exist, Rudy wish Google Maps users can be helped in planning trips back and forth.

What I Can Teach You About Companies

Importance to Choose the Best Digital Marketing Agency

Every online business owner would want to get more shoppers and clients to their online stores and also get better awareness. If you want to get those benefits, you will have to get some help from another organization who specializes in those kinds of tasks. That organization you are looking for will be a digital marketing agency and you need to choose the best one. You need to consider a lot of things and be careful about the company you will be hiring. Do not worry because this article is all about giving tips to business owners on how to hire the best digital marketing agency in the area.

Be sure to choose a digital marketing agency that will have good experience and reputation.

You will never hire professional that will have no experience with doing their job in the real world or in their field, right? And this goes the same with the digital marketing agency, you will never hire an agency that has little or no experience with digital marketing activities and strategies. You need to focus on finding a company that will have good employees and staff that are all reliable in the said field. You should know that they will be more expensive than the others. You will seriously get better returns from the investment that you spent on hiring the best digital marketing agency, they will have everything that your company will need for online marketing strategy.

Checking for their previous work will be important to you.

A lot of companies will try to say a lot of things to get hired and ending up with disappointing the client because they actually can’t deliver. You can ask any digital marketing agency that you want to hire to show you their previous works and you can also get some referrals from previous clients. You can go on ahead and use the internet for this kind of task, you will be able to see the feedbacks from previous clients and comments about their service, this can be found in the digital marketing agency’s website. You can do some case study on web pages and websites if a digital marketing agency will agree, an example of an agency that has this kind of process is Digital Hothouse.

You need to know about the service that they are able to provide once they are hired, that is going to be really important.

By following these guides and tips, you will be able to find the best digital marketing agency for you and your company, that is why you should focus on understanding this article as well.

Suggested Post: her explanation

The Apache Software Foundation Announces Apache(tm) Mesos(tm) as a Top-Level Project

The Apache Software Foundation (ASF), the all-volunteer developers, stewards, and incubators of nearly 150 Open Source projects and initiatives, announced today that Apache Mesos has graduated from the Apache Incubator to become a Top-Level Project (TLP), signifying that the project’s community and products have been well-governed under the ASF’s meritocratic process and principles.

Apache Mesos is a cluster manager that provides efficient resource isolation and sharing across distributed applications, or frameworks. It can run multiple frameworks, including Apache Hadoop, MPI, Hypertable, Jenkins, Storm, and Spark, as well as other applications and custom frameworks.

“It was our goal all along to see Mesos become a kernel of the infrastructure stack of the future,” said Benjamin Hindman, Vice President of Apache Mesos. “The project’s graduation from the Apache Incubator is recognition that the software is mature and has brought together a diverse community to sustain it in the future.”

Initially created at the University of California at Berkeley’s AMPLab (the research center also responsible for the original development of Apache Spark) to manage resource sharing and isolation in data centers, Mesos acts as a layer of abstraction between applications and pools of servers. Mesos helps avoid the necessity of creating separate clusters to run individual frameworks and instead making it possible to optimize how jobs are executed across shared machines.

Whilst in the Apache Incubator, Mesos had four releases, and established an Open Source community according to The Apache Way of governance. Additional improvements to the project includes its flexibility to support several application framework languages, and scalability that has been production tested to thousands of nodes and simulated to tens of thousands of nodes and hundreds of frameworks.

Apache Mesos has proven to be reliable for use in production, and has already been adopted by several organizations for cluster management.

“Mesos is the cornerstone of our elastic compute infrastructure,” explained Chris Fry, Senior Vice President of Engineering at Twitter. “It’s how we build all our new services and is critical for Twitter’s continued success at scale … one of the primary keys to our data infrastructure efficiency.”

“We’re using Mesos to manage cluster resources for most of our data infrastructure,” said Brenden Matthews, Engineer at Airbnb and Apache Mesos Committer. “We run Chronos, Storm, and Hadoop on top of Mesos in order to process petabytes of data.” (Chronos is an Airbnb-developed Mesos framework as a replacement for cron, and an example of how custom frameworks can be developed on Mesos to leverage its resource sharing).

“Community support for Apache Mesos is encouraging, particularly as more companies assess how they manage their clusters and look for more efficiency,” added Hindman. “Now that we’ve graduated, we look forward to continuing to grow the number of Mesos adopters and fostering an ecosystem around the project.”

Availability and Oversight
As with all Apache products, Apache Mesos software is released under the Apache License v2.0, and is overseen by a self-selected team of active contributors to the project. A Project Management Committee (PMC) guides the Project’s day-to-day operations, including community development and product releases.

Genius SlimStar T8020, a New Wireless Keyboard Touchpad Equipped

Electronic products on the market today are very diverse. With the extraordinary amount of money, no wonder the producers is unique in its product offering. It is also owned by the latest wireless keyboard called the Genius SlimStar T8020.

This wireless keyboard uniqueness lies in his numerical pad. Numpad keyboard can also be used should a touchpad. And like the touchpad in general, the numpad also support Windows 8 gesture.

To change the function of the touchpad is not overly difficult. This keyboard user need only press a button MODE.

In addition to the uniqueness of the touchpad, wireless keyboard has a button on the keyboard as well as 11 other function keys. As a complement, the keyboard is also coupled with the 2.4GHz USB pico receiver that allows you to connect the keyboard to the PC. Regarding the price, this keyboard is priced at 44.90 USD.

Review: Seagate Wireless Plus

The storage capacity is relatively limited tablet often makes us have to be smart to choose which content you want to keep in it. Not realizing it, remove and insert the digital content such as music video and it turns out that quite a lot of time consuming.
Well, one of the more clever solution is to use an external hard disk as Wi-Fi. Seagate Wireless Plus (SWP) is the replacement for the Seagate GoFlex Wireless (SGW) which appeared in 2011. There are some improvements that are owned SWP as larger capacity, longer battery life, as well as support for streaming 8 connections at once. The size is also smaller than SGW, and attractive, the price is not much different from SGW.
To fill the data into SWP, you just connect it to a PC via a fast USB 3.0 connection. If desired, you can replace with Thunderbolt or Firewire connector (sold separately). SWP is very easy to operate. You simply press the on / off button is there, then set your device to connect via Wi-Fi access point to the SWP. While connected to the SWP, you can still connect to the Internet by connecting the device to a Wi-Fi hotspot through SeagateMedia application available free on Play Store and AppStore.
Review: Seagate Wireless Plus review gadget mobile gadget accessories Review: Seagate Wireless Plus review gadget mobile gadget accessories Review: Seagate Wireless Plus review gadget mobile gadget accessories
Wireless Plus has been arranged with several standard folders such as Videos, Music, Photos, and Documents. But you can create your own folders if desired. SeagateMedia application quite well, but does not support all video formats. To music, more fully supported formats. As for the documents, Seagate will ask what application you want to use to open the document. I tried it on the Galaxy Note 10.1 and the Apple iPad 3. The results are quite varied and SWP proved more smoothly used in the Android platform, especially for video playback.
seagate wireless plus 1 Review: Seagate Wireless Plus review gadget mobile gadget accessories
Review: Seagate Wireless Plus
Full HD video in a streaming format. MP4 can be done smoothly, while for the format. Above 1GB MKV, a little choked up. This is not a problem in the SWP, but more to the software problem. Fortunately
You can use other applications to play the video. SWP battery is claimed to last up to 10 hours. But if you continue to take streaming video, then the battery will be filled after 6-7 hours. If it varies, then the battery will be able to last up to 9-10 hours.
Seagate Wireless Plus is an easy to use, very handy, and will remain relevant for longer than a new gadget you bought. The price is quite high, but the ability is quite worth it.

Integrating C++ with QML

Introduction

Qt Quick’s QML language makes it easy to do many things, especially fancy animated user interfaces. However, some things either can’t be done or are not suitable for implementing in QML, such as:

  1. Getting access to functionality outside of the QML/JavaScript environment.
  2. Implementing performance critical functions where native code is desired for efficiency.
  3. Large and/or complex non-declarative code that would be tedious to implement in JavaScript.

As we’ll see, Qt makes it quite easy to expose C++ code to QML. In this blog post I will show an example of doing this with a small but functional application.

The example is written for Qt 5 and uses the Qt Quick Components so you will need at least Qt version 5.1.0 to run it.

Overview

To expose a C++ type having properties, methods, signals, and/or slots to the QML environment, the basic steps are:

  1. Define a new class derived from QObject.
  2. Put the Q_OBJECT macro in the class declaration to support signals and slots and other services of the Qt meta-object system.
  3. Declare any properties using the Q_PROPERTY macro.
  4. Call qmlRegisterType() in your C++ main program to register the type with the Qt Quick engine.

For all the details I refer you to the Qt documentation section Exposing Attributes of C++ Types to QML and the Writing QML Extensions with C++ tutorial.

Ssh Key Generator

For our code example, we want a small application that will generate ssh public/private key pairs using a GUI. It will present the user with controls for the appropriate options and then run the program ssh-keygen to generate the key pair.

I implemented the user interface using the new Qt Quick Controls since it was intended as a desktop application with a desktop look and feel. I initially developed the UX entirely by running the qmlscene program directly on the QML source.

The UI prompts the user for the key type, the file name of the private key to generate and an optional pass phrase, which needs to be confirmed.

The C++ Class

Now that have the UI, we will want to implement the back end functionality. You can’t invoke an external program directly from QML so we have to write it in C++ (which is the whole point of this example application).

First, we define a class that encapsulates the key generation functionality. It will be exposed as a new class KeyGenerator in QML. This is done in the header file KeyGenerator.h below.

#ifndef KEYGENERATOR_H
#define KEYGENERATOR_H

#include <QObject>
#include <QString>
#include <QStringList>

// Simple QML object to generate SSH key pairs by calling ssh-keygen.

class KeyGenerator : public QObject
{
    Q_OBJECT
    Q_PROPERTY(QString type READ type WRITE setType NOTIFY typeChanged)
    Q_PROPERTY(QStringList types READ types NOTIFY typesChanged)
    Q_PROPERTY(QString filename READ filename WRITE setFilename NOTIFY filenameChanged)
    Q_PROPERTY(QString passphrase READ filename WRITE setPassphrase NOTIFY passphraseChanged)

public:
    KeyGenerator();
    ~KeyGenerator();

    QString type();
    void setType(const QString &t);

    QStringList types();

    QString filename();
    void setFilename(const QString &f);

    QString passphrase();
    void setPassphrase(const QString &p);

public slots:
    void generateKey();

signals:
    void typeChanged();
    void typesChanged();
    void filenameChanged();
    void passphraseChanged();
    void keyGenerated(bool success);

private:
    QString _type;
    QString _filename;
    QString _passphrase;
    QStringList _types;
};
#endif

Next, we need to derive our class from QObject. We declare any properties that we want and the associated methods. Notify methods become signals. In our case, we want to have properties for the selected key type, the list of all valid ssh key types, file name and pass phrase. I arbitrarily made the key type a string. It could have been an enumerated type but it would have made the example more complicated.

Incidentally, a new feature of the Q_PROPERTY macro in Qt 5.1.0 is the MEMBER argument. It allows specifying a class member variable that will be bound to a property without the need to implement the setter or getter functions. That feature was not used here.

We declare methods for the setters and getters and for signals. We also declare one slot called generateKey(). These will all be available to QML. If we wanted to export a regular method to QML, we could mark it with Q_INVOCABLE. In this case I decided to make generateKey() a slot since it might be useful in the future but it could have just as easily been an invocable method.

Finally, we declare any private member variables we will need.

C++ Implementation

Now let’s look at the implementation in KeyGenerator.cpp. Here is the source code:

#include <QFile>
#include <QProcess>
#include "KeyGenerator.h"

KeyGenerator::KeyGenerator()
    : _type("rsa"), _types{"dsa", "ecdsa", "rsa", "rsa1"}
{
}

KeyGenerator::~KeyGenerator()
{
}

QString KeyGenerator::type()
{
    return _type;
}

void KeyGenerator::setType(const QString &t)
{
    // Check for valid type.
    if (!_types.contains(t))
        return;

    if (t != _type) {
        _type = t;
        emit typeChanged();
    }
}

QStringList KeyGenerator::types()
{
    return _types;
}

QString KeyGenerator::filename()
{
    return _filename;
}

void KeyGenerator::setFilename(const QString &f)
{
    if (f != _filename) {
        _filename = f;
        emit filenameChanged();
    }
}

QString KeyGenerator::passphrase()
{
    return _passphrase;
}

void KeyGenerator::setPassphrase(const QString &p)
{
    if (p != _passphrase) {
        _passphrase = p;
        emit passphraseChanged();
    }
}

void KeyGenerator::generateKey()
{
    // Sanity check on arguments
    if (_type.isEmpty() or _filename.isEmpty() or
        (_passphrase.length() > 0 and _passphrase.length() < 5)) {
        emit keyGenerated(false);
        return;
    }

    // Remove key file if it already exists
    if (QFile::exists(_filename)) {
        QFile::remove(_filename);
    }

    // Execute ssh-keygen -t type -N passphrase -f keyfileq
    QProcess *proc = new QProcess;
    QString prog = "ssh-keygen";
    QStringList args{"-t", _type, "-N", _passphrase, "-f", _filename};
    proc->start(prog, args);
    proc->waitForFinished();
    emit keyGenerated(proc->exitCode() == 0);
    delete proc;
}

The constructor initializes some of the member variables. For fun, I used the new initializer list feature of C++11 to initialize the _types member variable which is of type QStringList. The destructor does nothing, at least for now, but is there for completeness and future expansion.

Getter functions like type() simply return the appropriate private member variable. Setters set the appropriate variables, taking care to check that the new value is different from the old one and if so, emitting the appropriate signal. As always, please note that signals are created by the Meta Object Compiler and do not need to be implemented, only emitted at the appropriate times.

The only non-trivial method is the slot generateKey(). It does some checking of arguments and then creates a QProcess to run the external ssh-keygen program. For simplicity and because it typically executes quickly, I do this synchronously and block on it to complete. When done, we emit a signal that has a boolean argument that indicates the key was generated and whether it succeeded or not.

QML Code

Now let’s look at the QML code in main.qml:

// SSH key generator UI

import QtQuick 2.1
import QtQuick.Controls 1.0
import QtQuick.Layouts 1.0
import QtQuick.Dialogs 1.0
import com.ics.demo 1.0

ApplicationWindow {
    title: qsTr("SSH Key Generator")

    statusBar: StatusBar {
    RowLayout {
        Label {
            id: status
            }
        }
    }

    width: 369
    height: 166

    ColumnLayout {
        x: 10
        y: 10

        // Key type
        RowLayout {
            Label {
                text: qsTr("Key type:")
            }
            ComboBox {
                id: combobox
                Layout.fillWidth: true
                model: keygen.types
                currentIndex: 2
            }
        }

        // Filename
        RowLayout {
            Label {
                text: qsTr("Filename:")
            }
            TextField {
                id: filename
                implicitWidth: 200
                onTextChanged: updateStatusBar()
            }
            Button {
                text: qsTr("&Browse...")
                onClicked: filedialog.visible = true
            }
        }

        // Passphrase
        RowLayout {
            Label {
                text: qsTr("Pass phrase:")
            }
            TextField {
                id: passphrase
                Layout.fillWidth: true
                echoMode: TextInput.Password
                onTextChanged: updateStatusBar()
            }

        }

        // Confirm Passphrase
        RowLayout {
            Label {
                text: qsTr("Confirm pass phrase:")
            }
            TextField {
                id: confirm
                Layout.fillWidth: true
                echoMode: TextInput.Password
                onTextChanged: updateStatusBar()
            }
        }

        // Buttons: Generate, Quit
        RowLayout {
            Button {
                id: generate
                text: qsTr("&Generate")
                onClicked: keygen.generateKey()
            }
            Button {
                text: qsTr("&Quit")
                onClicked: Qt.quit()
            }
        }

    }

    FileDialog {
        id: filedialog
        title: qsTr("Select a file")
        selectMultiple: false
        selectFolder: false
        nameFilters: 
        selectedNameFilter: "All files (*)"
        onAccepted: {
            filename.text = fileUrl.toString().replace("file://", "")
        }
    }

    KeyGenerator {
        id: keygen
        filename: filename.text
        passphrase: passphrase.text
        type: combobox.currentText
        onKeyGenerated: {
            if (success) {
                status.text = qsTr('<font color="green">Key generation succeeded.</font>')
            } else {
                status.text = qsTr('<font color="red">Key generation failed</font>')
            }
        }
    }

    function updateStatusBar() {
        if (passphrase.text != confirm.text) {
            status.text = qsTr('<font color="red">Pass phrase does not match.</font>')
            generate.enabled = false
        } else if (passphrase.text.length > 0 && passphrase.text.length < 5) {
            status.text = qsTr('<font color="red">Pass phrase too short.</font>')
            generate.enabled = false
        } else if (filename.text == "") {
            status.text = qsTr('<font color="red">Enter a filename.</font>')
            generate.enabled = false
        } else {
            status.text = ""
            generate.enabled = true
        }
    }

    Component.onCompleted: updateStatusBar()
}

The preceding code is a little long, however, much of the work is laying out the GUI components. The code should be straightforward to follow.

Note that we import com.ics.demo version 1.0. We’ll see where this module name comes from shortly. This makes a new QML type KeyGeneratoravailable and so we declare one. We have access to it’s C++ properties as QML properties, can call it’s methods and act on signals like we do withonKeyGenerated.

A more complete program should probably do a little more error checking and report meaningful error messages if key generation fails (we could easily add a new method or property for this). The UI layout could also be improved to make it properly resizable.

Our main program is essentially a wrapper like qmlscene. All we need to do to register our type with the QML engine is to call:

    qmlRegisterType<KeyGenerator>("com.ics.demo", 1, 0, "KeyGenerator");

This makes the C++ type KeyGenerator available as the QML type KeyGenerator in the module com.ics.demo version 1.0 when it is imported.

Typically, to run QML code from an executable, in the main program you would create a QGuiApplication and a QQuickView. Currently, to use the Qt Quick Components there is some additional work needed if the top level element is an ApplicationWindow or Window. You can look at the source code to see how I implemented this. I basically stripped down the code from qmlscene to the minimum of what was needed for this example.

Here is the full listing for the main program, main.cpp:

#include <QApplication>
#include <QObject>
#include <QQmlComponent>
#include <QQmlEngine>
#include <QQuickWindow>
#include <QSurfaceFormat>
#include "KeyGenerator.h"

// Main wrapper program.
// Special handling is needed when using Qt Quick Controls for the top window.
// The code here is based on what qmlscene does.

int main(int argc, char ** argv)
{
    QApplication app(argc, argv);

    // Register our component type with QML.
    qmlRegisterType<KeyGenerator>("com.ics.demo", 1, 0, "KeyGenerator");

    int rc = 0;

    QQmlEngine engine;
    QQmlComponent *component = new QQmlComponent(&engine);

    QObject::connect(&engine, SIGNAL(quit()), QCoreApplication::instance(), SLOT(quit()));

    component->loadUrl(QUrl("main.qml"));

    if (!component->isReady() ) {
        qWarning("%s", qPrintable(component->errorString()));
        return -1;
    }

    QObject *topLevel = component->create();
    QQuickWindow *window = qobject_cast<QQuickWindow *>(topLevel);

    QSurfaceFormat surfaceFormat = window->requestedFormat();
    window->setFormat(surfaceFormat);
    window->show();

    rc = app.exec();

    delete component;
    return rc;
}

In case it is not obvious, when using a module written in C++ with QML you cannot use the qmlscene program to execute your QML code because the C++ code for the module will not be linked in. If you try to do this you will get an error message that the module is not installed.