Hi,
2011/4/15 Hugo Parente Lima <[email protected]>:
> On Friday 15 April 2011 15:10:35 Eli Stevens (Gmail) wrote:
>> Cool. This is last on the list from my PoV, since the consistency and
>> correctness issues in 2 and 3 above are more important than strict
>> backwards compatibility to me. Obviously, I'm just a user, so my
>> opinion doesn't carry as much weight as if I were in a position to
>> contribute patches, I just wanted to make sure my position was clearly
>> expressed (it seemed like a lot of what I was trying to say wasn't
>> being understood the way I intended; apologies if I was unclear).
>
> Yes, your opinion is import and I understand that the current state isn't
> perfect, I'm just saying that as the problem is in another layer (Qt) we have
> just a limited amount of options to deal with the problem and those options
> aren't backwards compatible.
What you can do in C++ and can't do in Python at the moment is use
QVariant to convert data. If there would be a function convert(value,
type) in Python where value is any value that the QVariant constructor
accepts, and "type" is a Python type that QVariant can be converted
to, the convert function could internally use the C++ implementation
of QVariant to carry out the conversion for us. I.e. we could do this
then:
s = QSettings()
v = s.value('x')
b = convert(v, bool)
What convert does internally is (in C++):
// the first parameter "x"
QString x;
QVariant v(x);
// pick the right to<...>() function based on the second parameter
return v.toBool();
Would this solve the problem? If so, would it be feasible to add this
somewhere to the PySide Python API? It would just expose the
converting ability of QVariant to the Python world without exposing
QVariant directly.
HTH.
Thomas
_______________________________________________
PySide mailing list
[email protected]
http://lists.pyside.org/listinfo/pyside