Results 1 to 4 of 4

Thread: QCombobox Plugin - how ?

  1. #1
    Join Date
    Apr 2007
    Location
    Sunny Darwin, NT Australia
    Posts
    186
    Qt products
    Qt4
    Platforms
    Unix/X11
    Thanks
    29
    Thanked 5 Times in 5 Posts

    Default QCombobox Plugin - how ?

    I've made a designer widget but it has some shortcomings.
    It's basically a combobox with some added functionality, but when I use it in the gui editor it doesn't come up in the tab order list and setFocus() doesn't work. I think it's because I've derived my part from QWidget, I tried changing the base class to QComboBox but it doesn't compile. The alternative is to subclass setFocous() and then do cb.setFocus() from within the class but this is not a proper solution

    dbcomboboxplugin.cpp: In function ‘QObject* qt_plugin_instance()’:
    dbcomboboxplugin.cpp:91: error: cannot allocate an object of abstract type ‘DbComboBoxPlugin’
    dbcomboboxplugin.h:9: note: because the following virtual functions are pure within ‘DbComboBoxPlugin’:
    /usr/include/qt4/QtDesigner/customwidget.h:71: note: virtual QWidget* QDesignerCustomWidgetInterface::createWidget(QWidg et*)
    I've attached the 2 header files.
    Attached Files Attached Files

  2. #2
    Join Date
    Jan 2008
    Location
    Poland
    Posts
    687
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Thanks
    4
    Thanked 140 Times in 132 Posts

    Default Re: QCombobox Plugin - how ?

    You didn't implement required pure virtual method so your class it is abstract so you can't have an instance (object) of an abstract class. Did you read Designer plugin example in Assistant? There is all you need to know. You have a:
    Qt Code:
    1. QComboBox *createWidget(QComboBox *parent);
    To copy to clipboard, switch view to plain text mode 
    in your header. So it is your own additional method in DbComboBoxPlugin.
    You don't have
    Qt Code:
    1. QWidget *createWidget(QWidget *parent);
    To copy to clipboard, switch view to plain text mode 
    which is pure virtual in QDesignerCustomWidgetInterface so you have to implement it in your QDesignerCustomWidgetInterface implementation which is DbComboBoxPlugin in your case.

    I think that it was just a mistake to write QComboBox instead of QWidget, but if not, then try to renew your knowledge about C++ Overriding.
    I would like to be a "Guru"

    Useful hints (try them before asking):
    1. Use Qt Assistant
    2. Search the forum

    If you haven't found solution yet then create new topic with smart question.

  3. #3
    Join Date
    Apr 2007
    Location
    Sunny Darwin, NT Australia
    Posts
    186
    Qt products
    Qt4
    Platforms
    Unix/X11
    Thanks
    29
    Thanked 5 Times in 5 Posts

    Default Re: QCombobox Plugin - how ?

    I did read the example, my earlier version that compiled did have:
    Qt Code:
    1. QWidget *createWidget(QWidget *parent);
    To copy to clipboard, switch view to plain text mode 
    as per the example,and in the implementation file:
    Qt Code:
    1. QWidget *DbComboBoxPlugin::createWidget(QWidget *parent)
    2. {
    3. return new DbComboBox(parent);
    4. }
    To copy to clipboard, switch view to plain text mode 
    (Is this not C++ over-riding ? if not, I have not understood it at all).
    This is creating an instance, but I'm not seeing all of QComboBox features.
    What am I missing then?

  4. #4
    Join Date
    Apr 2007
    Location
    Sunny Darwin, NT Australia
    Posts
    186
    Qt products
    Qt4
    Platforms
    Unix/X11
    Thanks
    29
    Thanked 5 Times in 5 Posts

    Default Re: QCombobox Plugin - how ?

    no one got any idea or clue ?

Similar Threads

  1. Trouble with plugin system's documentation
    By niklas in forum Qt Programming
    Replies: 8
    Last Post: 6th March 2009, 23:07
  2. Plugin implementation question
    By JPNaude in forum Qt Programming
    Replies: 12
    Last Post: 27th August 2008, 21:24
  3. QPluginLoader not recognizing a plugin
    By KShots in forum Qt Programming
    Replies: 3
    Last Post: 29th June 2007, 15:13
  4. plugin loading problem
    By naresh in forum Qt Programming
    Replies: 6
    Last Post: 9th June 2007, 20:05
  5. Qt4 win opensource + mysql plugin
    By vr in forum Installation and Deployment
    Replies: 3
    Last Post: 25th May 2007, 10:01

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
  •  
Qt is a trademark of The Qt Company.