Results 1 to 7 of 7

Thread: driver plugin help

  1. #1
    Join Date
    Nov 2006
    Posts
    6
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default driver plugin help

    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

    Qt Code:
    1. #include <QKbdDriverPlugin>
    2. #include <QtPlugin>
    3. #include <QtCore>
    4. #include <QWSKeyboardHandler>
    5. class CustomKBPlugin : public QKbdDriverPlugin
    6. {
    7. public:
    8. QWSKeyboardHandler* create(const QString &key, const QString &device);
    9. QStringList keys() const;
    10. };
    To copy to clipboard, switch view to plain text mode 

    the implementation...
    Qt Code:
    1. #include "ckplugin.h"
    2. #include <QDebug>
    3. #include <QtPlugin>
    4. QWSKeyboardHandler* CustomKBPlugin::create(const QString &key, const QString &device)
    5. {
    6. qDebug() << "creating device";
    7. return new QWSKeyboardHandler("/dev/tty");
    8. return 0;
    9. }
    10.  
    11. QStringList CustomKBPlugin::keys() const
    12. {
    13. return QStringList() << "sample keys";
    14. }
    15.  
    16. Q_EXPORT_PLUGIN2(ckbplugin, CustomKBPlugin)
    To copy to clipboard, switch view to plain text mode 

    the .pro
    Qt Code:
    1. TEMPLATE = lib
    2. TARGET = ckplugin
    3. DEPENDPATH += .
    4. INCLUDEPATH += .
    5. CONFIG += plugin
    6.  
    7. # Input
    8. HEADERS += ckplugin.h
    9. SOURCES += ckplugin.cpp
    To copy to clipboard, switch view to plain text mode 

    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.
    Last edited by jacek; 14th November 2006 at 09:43. Reason: changed [code] to [quote]

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: driver plugin help

    Quote Originally Posted by psi View Post
    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.

  3. The following user says thank you to jacek for this useful post:

    psi (15th November 2006)

  4. #3
    Join Date
    Nov 2006
    Posts
    6
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: driver plugin help

    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....

  5. #4
    Join Date
    Nov 2006
    Posts
    6
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: driver plugin help

    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.

  6. #5
    Join Date
    May 2006
    Location
    Germany
    Posts
    108
    Thanks
    2
    Thanked 14 Times in 12 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: driver plugin help

    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

    Thanks a lot in advance.
    Last edited by Methedrine; 24th December 2006 at 14:51.

  7. #6
    Join Date
    Nov 2006
    Posts
    6
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: driver plugin help

    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.

  8. #7
    Join Date
    May 2006
    Location
    Germany
    Posts
    108
    Thanks
    2
    Thanked 14 Times in 12 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: driver plugin help

    Quote Originally Posted by psi View Post
    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 :-)

Similar Threads

  1. plugin loading problem
    By naresh in forum Qt Programming
    Replies: 6
    Last Post: 9th June 2007, 19:05
  2. Testing a custom Plugin
    By maluta in forum Qt Programming
    Replies: 5
    Last Post: 31st October 2006, 15:09
  3. MySql plugin driver issues
    By stevey in forum Installation and Deployment
    Replies: 11
    Last Post: 20th September 2006, 13:45
  4. Managing widget plugin in Qt Designer
    By yellowmat in forum Newbie
    Replies: 8
    Last Post: 31st January 2006, 09:58

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.