I'm using Qt 4.5.2 and Qt 4 Visual Studio Add-In.
I've created a custom widget plugin for Qt Designer with Visual Studio's Qt Plugin template.
The widget itself shows up in Qt Designer and works correctly if I compile a Qt Application Project which includes the plugin.
Additionally, the widget implements custom signals and slots.
Since I would like to use Visual Studio's Qt Application template and Qt Designer, I want these signals and slots to show up in Qt Designer, so I don't have to add them manually in the generated code files.
To achieve that, I've tried to implement my own Member Sheet Extension.
The plugin actually compiles without any errors or warnings, but if I try to open the popup menus in the "signals and slots" window in Qt Designer, it crashes.
Unfortunately, it doesn't give me any error messages or exceptions, it just shuts down.
So, I guess my implementation of QDesignerMemberSheetExtension isn't correct or contains a bad method, but I don't have any clues what the problem is.
So far, I couldn't find a correct example implementation either so I can't compare my code to a working plugin.
I took the Task Menu Extension Example, QDesignerMemberSheetExtension and QExtensionFactory as reference.
To implement the membersheet methods, I use QMetaObject and QMetaMethod:
Qt4D3DCMemberSheetExtension
::Qt4D3DCMemberSheetExtension(Qt4Direct3DContainer
*p_d3dc,
QObject *parent
) : QObject(parent
){
m_qt4D3DC = p_d3dc;
m_qMetaObject = m_qt4D3DC->metaObject();
}
Qt4D3DCMemberSheetExtension::Qt4D3DCMemberSheetExtension(Qt4Direct3DContainer *p_d3dc, QObject *parent) : QObject(parent)
{
m_qt4D3DC = p_d3dc;
m_qMetaObject = m_qt4D3DC->metaObject();
}
To copy to clipboard, switch view to plain text mode
bool Qt4D3DCMemberSheetExtension::isSignal( int index ) const
{
}
bool Qt4D3DCMemberSheetExtension::isSignal( int index ) const
{
QMetaMethod method = m_qMetaObject->method(index);
return method.methodType() == QMetaMethod::Signal;
}
To copy to clipboard, switch view to plain text mode
Is that a reasonable thing to do?
I took the implementation of the QExtensionFactory code primarily from the Task Menu Extension Example:
{
return 0;
if (Qt4Direct3DContainer *widget = qobject_cast<Qt4Direct3DContainer*>(object))
{
return new Qt4D3DCMemberSheetExtension(widget, parent);
}
return NULL;
}
QObject * Qt4D3DCExtensionFactory::createExtension(QObject *object, const QString &iid, QObject *parent) const
{
if (iid != Q_TYPEID(QDesignerMemberSheetExtension))
return 0;
if (Qt4Direct3DContainer *widget = qobject_cast<Qt4Direct3DContainer*>(object))
{
return new Qt4D3DCMemberSheetExtension(widget, parent);
}
return NULL;
}
To copy to clipboard, switch view to plain text mode
{
if (initialized)
return;
Q_ASSERT(manager != 0);
initialized = true;
}
void Qt4Direct3DContainerPlugin::initialize(QDesignerFormEditorInterface *formEditor)
{
if (initialized)
return;
QExtensionManager *manager = formEditor->extensionManager();
Q_ASSERT(manager != 0);
manager->registerExtensions(new Qt4D3DCExtensionFactory(manager), Q_TYPEID(QDesignerMemberSheetExtension));
initialized = true;
}
To copy to clipboard, switch view to plain text mode
Has anything gone wrong there?
Is there any reasonable way of debugging a custom widget plugin?
Bookmarks