psi
14th November 2006, 08:48
Hi, I've been following the plugin guide from qt assistant, but there doesn't seem to be any examples for device driver plugins, so I tried to write one but only to find it not compilable for reasons beyond my understanding.
here's the header
#include <QKbdDriverPlugin>
#include <QtPlugin>
#include <QtCore>
#include <QWSKeyboardHandler>
class CustomKBPlugin : public QKbdDriverPlugin
{
public:
QWSKeyboardHandler* create(const QString &key, const QString &device);
QStringList keys() const;
};
the implementation...
#include "ckplugin.h"
#include <QDebug>
#include <QtPlugin>
QWSKeyboardHandler* CustomKBPlugin::create(const QString &key, const QString &device)
{
qDebug() << "creating device";
return new QWSKeyboardHandler("/dev/tty");
return 0;
}
QStringList CustomKBPlugin::keys() const
{
return QStringList() << "sample keys";
}
Q_EXPORT_PLUGIN2(ckbplugin, CustomKBPlugin)
the .pro
TEMPLATE = lib
TARGET = ckplugin
DEPENDPATH += .
INCLUDEPATH += .
CONFIG += plugin
# Input
HEADERS += ckplugin.h
SOURCES += ckplugin.cpp
the error...
..../qtopia-core-opensource-src-4.2.0/include -I. -I. -I. -o ckplugin.o ckplugin.cpp
ckplugin.cpp:6: warning: unused parameter 'key'
ckplugin.cpp:6: warning: unused parameter 'device'
ckplugin.cpp: In function `QObject* qt_plugin_instance()':
ckplugin.cpp:16: error: cannot allocate an object of type `CustomKBPlugin'
ckplugin.cpp:16: error: because the following virtual functions are abstract:
..../qtopia-core-opensource-src-4.2.0/include/QtGui/../../src/gui/embedded/qkbddriverplugin_qws.h:40: error: virtual QWSKeyboardHandler* QWSKeyboardHandlerFactoryInterface::create(const QString&)
{standard input}: Assembler messages:
{standard input}:582: Error: displacement to undefined symbol .LTHUNK1 overflows 12-bit field
{standard input}:591: Error: displacement to undefined symbol .LTHUNK2 overflows 12-bit field
I know I didn't include the actual driver implmentations here, but this sample code alone causes the compilation problem.
If I added Q_Object, it would remove the last few assembly errors, but still doesn't solve the problem with virtual function of QWSKeyboardHandlerFactoryInterface
Any help is welcome, thank you.
here's the header
#include <QKbdDriverPlugin>
#include <QtPlugin>
#include <QtCore>
#include <QWSKeyboardHandler>
class CustomKBPlugin : public QKbdDriverPlugin
{
public:
QWSKeyboardHandler* create(const QString &key, const QString &device);
QStringList keys() const;
};
the implementation...
#include "ckplugin.h"
#include <QDebug>
#include <QtPlugin>
QWSKeyboardHandler* CustomKBPlugin::create(const QString &key, const QString &device)
{
qDebug() << "creating device";
return new QWSKeyboardHandler("/dev/tty");
return 0;
}
QStringList CustomKBPlugin::keys() const
{
return QStringList() << "sample keys";
}
Q_EXPORT_PLUGIN2(ckbplugin, CustomKBPlugin)
the .pro
TEMPLATE = lib
TARGET = ckplugin
DEPENDPATH += .
INCLUDEPATH += .
CONFIG += plugin
# Input
HEADERS += ckplugin.h
SOURCES += ckplugin.cpp
the error...
..../qtopia-core-opensource-src-4.2.0/include -I. -I. -I. -o ckplugin.o ckplugin.cpp
ckplugin.cpp:6: warning: unused parameter 'key'
ckplugin.cpp:6: warning: unused parameter 'device'
ckplugin.cpp: In function `QObject* qt_plugin_instance()':
ckplugin.cpp:16: error: cannot allocate an object of type `CustomKBPlugin'
ckplugin.cpp:16: error: because the following virtual functions are abstract:
..../qtopia-core-opensource-src-4.2.0/include/QtGui/../../src/gui/embedded/qkbddriverplugin_qws.h:40: error: virtual QWSKeyboardHandler* QWSKeyboardHandlerFactoryInterface::create(const QString&)
{standard input}: Assembler messages:
{standard input}:582: Error: displacement to undefined symbol .LTHUNK1 overflows 12-bit field
{standard input}:591: Error: displacement to undefined symbol .LTHUNK2 overflows 12-bit field
I know I didn't include the actual driver implmentations here, but this sample code alone causes the compilation problem.
If I added Q_Object, it would remove the last few assembly errors, but still doesn't solve the problem with virtual function of QWSKeyboardHandlerFactoryInterface
Any help is welcome, thank you.