PDA

View Full Version : driver plugin help



psi
14th November 2006, 09: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.

jacek
14th November 2006, 22:42
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&)
It looks like you have to implement CustomKBPlugin::create(const QString &key) too.

It's a bit weird, because it isn't documented, but I've grepped Qtopia sources and it appears that both versions are used. IMO you should ask the Trolls, because something might be missing from the documentation.

psi
15th November 2006, 04:41
It works if I implment the function you suggested.
I'm beginning to suspect it might have been a documentation error.
Let's see if it works when the actual driver implemention is done....;)

psi
23rd November 2006, 05:15
It has been confirmed that there has been documentation errors.
However, I'm still having all sorts of trouble getting the pluging to work. So far I've got it to load, but unable to create an instance of the driver plugin.

Methedrine
24th December 2006, 15:33
I am getting the same compile error with Qt 4.2.1 - any advice on how you solved this problem (my pure virtual functions are all implemented)? I just wasted the whole day so far :rolleyes:

Thanks a lot in advance.

psi
25th December 2006, 05:01
sorry I can't really help you here because I basically skipping using the driver plugin
It's because the platform I'm using has a proprietary driver layer, so I just wrap it around with a timer to pull the values. I know it's not the best way to do it, but it works.
Like jacek said, there's a 2nd virtual function you need to implement. I confirmed it with the trolls, they said it's indeed a documentation error.

Methedrine
25th December 2006, 22:22
sorry I can't really help you here because I basically skipping using the driver plugin
It's because the platform I'm using has a proprietary driver layer, so I just wrap it around with a timer to pull the values. I know it's not the best way to do it, but it works.
Like jacek said, there's a 2nd virtual function you need to implement. I confirmed it with the trolls, they said it's indeed a documentation error.

Ok, thank you anyways :-)