QtInputContextFactory returning NULL on embedded target

113 views Asked by At

On my embedded system I don't have X11, Mac, Win, S60, etc. I keep getting a NULL ( 0 ) pointer returned from the create method of the QInputContextFactory class. I verified that QT_NO_LIBRARY is not defined.

On my Desktop Qt Build this works just fine.

I also verified that my custom key and parent are being passed to the method.

What could cause this to fail? -->

if (QInputContextFactoryInterface *factory =
        qobject_cast<QInputContextFactoryInterface*>(loader()->instance(key))) {
        result = factory->create(key);
    }

Here is the entire method:

QInputContext *QInputContextFactory::create( const QString& key, QObject *parent )
{
    QInputContext *result = 0;
#if defined(Q_WS_X11) && !defined(QT_NO_XIM)
    if (key == QLatin1String("xim")) {
        result = new QXIMInputContext;
    }
#endif
#if defined(Q_WS_WIN)
    if (key == QLatin1String("win")) {
        result = new QWinInputContext;
    }
#endif
#if defined(Q_WS_MAC)
    if (key == QLatin1String("mac")) {
        result = new QMacInputContext;
    }
#endif
#if defined(Q_WS_S60)
    if (key == QLatin1String("coefep")) {
        result = new QCoeFepInputContext;
    }
#endif
#ifdef QT_NO_LIBRARY
    Q_UNUSED(key);
#else
    qDebug() << "Here we are";
    if (QInputContextFactoryInterface *factory =
        qobject_cast<QInputContextFactoryInterface*>(loader()->instance(key))) {
        result = factory->create(key);
    }
#endif
    if (result)
        result->setParent(parent);
    return result;
}
1

There are 1 answers

0
RA. On BEST ANSWER

Within Qt, the QInputContextFactory class is front-end on loading input context plug-ins. It will fail to load an input context plug-in if it fails to exist, or hasn't been deployed properly. Input context plug-ins are typically stored under $QT_PLUGIN_PATH/inputmethods. As such, if there is no plug-in within that directory, the create method of the QInputContextFactory will return NULL.

Of note, Qt does provide a few mechanisms for customizing the location of plug-ins. Refer to the following for more detail on this:

http://qt-project.org/doc/qt-4.8/deployment-plugins.html