Hi,

I'm currently using PySide 1.0.9 (compiled against Python 2.5) in our Qt 
(v4.7.1)/C++ software, and I'm stuck 
with a MetaType/QVariant issue (in C++ side).
So here's a description of the problem:

When importing PySide modules in our application using an embedded python 
interpreter, PySide registers some 
metatypes to deal with Qt enums/flags. For instance:  

    qRegisterMetaType< ::Qt::Orientation >("Qt::Orientation");
    
These custom metatypes are added in a static list also used by the rest of the 
application.
The problem occurs when we use a QtDesigner component (the property sheet) 
which tries to retrieve the enum value
using the meta object system.
Once the "Qt::Orientation" has been added by the PySide import as a custom 
metaTypes, Qt is no longer able to convert 
the obtained QVariant into an integer, so that all the enum values retrieved 
using the metaproperty are incorrect.

Consider this code snippet that highlights  the problem:

QVariant QDesignerPropertySheet::metaProperty(int index) const
{
    Q_ASSERT(!isFakeProperty(index));

    const QDesignerMetaPropertyInterface *p = d->m_meta->property(index);
    QVariant v = p->read(d->m_object); 
>>    
     Here the QVariant has been created using a custom meta type 
(ex:Qt::Orientation)
     instead of using the standard QMetaType::Int type. This happens because Qt 
found 
     the typename "Qt::Orientation" in the custom meta types list
>>
    switch (p->kind()) {
    case QDesignerMetaPropertyInterface::FlagKind: {
        qdesigner_internal::PropertySheetFlagValue psflags = 
qdesigner_internal::PropertySheetFlagValue(v.toInt(), 
designerMetaFlagsFor(p->enumerator()));
        qVariantSetValue(v, psflags);
    }
        break;
    case QDesignerMetaPropertyInterface::EnumKind: {
        qdesigner_internal::PropertySheetEnumValue pse = 
qdesigner_internal::PropertySheetEnumValue(v.toInt(), 
designerMetaEnumFor(p->enumerator())); 
>>
    Here the QVariant::toInt() will fail to return the correct enum value
>>
        qVariantSetValue(v, pse);
    }


So, are any of you aware of this issue? 
Do you know of or can thing of a possible workaround?
I ask because this "behavior" is quite blocking for us, and preventing us from 
going further in our development.

Thanks,
Alberto Soto
_______________________________________________
PySide mailing list
PySide@lists.pyside.org
http://lists.pyside.org/listinfo/pyside

Reply via email to