[Kommander-devel] Making a Kommander editor using Designer 4
Andras Mantia
amantia at kde.org
Wed Apr 16 15:50:05 EDT 2008
Hi Eric,
On Wednesday 16 April 2008, Eric Laffoon wrote:
> QWidget *ButtonGroupKmdrDesignerPlugin::createWidget(QWidget *parent)
> {
> return new ButtonGroup(parent);
> }
>
> The compiler rightly points out this is not correct as the
> constructor requires another vairable, the name variable. However I
> added this locally so it calls
Assuming it is about the ButtonGroup widget inside
kde-trunk/kdewebdev/widgets the compiler was right. ;) But somehow I
don't understand why you want to create a ButtonGroup widget in a
plugin when there is one in the main Kommander. Ah, I see, this is
about the designer plugin.
First of all, I'm not happy at all that these classed ended up in the
widgets directory and the libkommanderwidgets plugin.
This plugin should have ONLY the widgets themselves. Otherwise we would
bloat the executor with designer (editor) specific code, and will make
moving of the executor to kdebase close to impossible.
If the problem is that you need access to the classes, we will find some
other solution.
> The changes to headers were made and everything is right... Except of
> course that I'm mucking with not just the widget constructor, but the
> virtual function in the QDesigner plugin. Now it is not happy...
>
> /home/eric/kdesvn/kdewebdev/kommander/widgets/kmdrdesignerwidgets.cpp
>:18: error: cannot allocate an object of abstract
> type 'ButtonGroupKmdrDesignerPlugin'
> /home/eric/kdesvn/kdewebdev/kommander/widgets/buttongroupkmdrdesigner
>plugin.h:26: note: because the following virtual functions are pure
> within 'ButtonGroupKmdrDesignerPlugin':
> /usr/local/Trolltech/Qt-4.4.0-beta1/include/QtDesigner/customwidget.h
>:73: note: virtual QWidget*
> QDesignerCustomWidgetInterface::createWidget(QWidget*)
This means that you inherit from an "abstract" class, that has abstract
(pure virtual) methods. Those are the methods declared as:
void methodName() = 0;
(or similar).
These methods are not implemented at all in the base class, this is why
they are abstract. The class also cannot be instantiated as an object.
So you need to subclass it (as I understood you did), and write the
implementation of the abstract methods (all of them!). So you need a
QWidget* createWidget(QWidget*);
declaration in the class header file, and the impelementation of this
method in the cpp file.
Now that I see this code, I'm wondering what is wrong. :)
Ok, so the problem here was only the (first) compiler error. There is no
complain about the pure virtual methods. So maybe you messed your local
checkout up by adding a name argument to the createWidget declaration?
> So what is happening with the name in the constructor?
Name is the object name assigned to the widget. In Qt3 all widgets had a
name argument. In Qt4 none of them has and you have to use
widget->setObjectName(name).
They are useful to find/identify an widget (or to be more precise,
QObject).
> Is Kommander
> being passed the widget name here?
No.
I hope this helps, I committed the "fixed" buttongroup stuff, but others
still failing. They need the same change though.
Andras
--
Quanta Plus developer - http://quanta.kdewebdev.org
K Desktop Environment - http://www.kde.org
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 194 bytes
Desc: This is a digitally signed message part.
Url : http://mail01.fortunecookiestudios.com/pipermail/kommander-devel/attachments/20080416/c6bae91c/attachment.pgp
More information about the Kommander-devel
mailing list