[Development] QVairant::Type enums are now obsolete?

Thiago Macieira thiago.macieira at intel.com
Mon Aug 20 17:42:51 CEST 2012


On segunda-feira, 20 de agosto de 2012 11.22.12, Stephen Chu wrote:
> I just noticed that all the QVariant::Type enums are now marked as
> obsolete in 5.0 doc:
> http://qt-project.org/doc/qt-5.0/qvariant-obsolete.html#Type-enum
> 
> The goal seems to be to switch to QMetaType enums. But in the attempt to
> make my code up-to-date, I find that strait replace of the old names
> with the new can be very problematic. For example the following 2 lines
> of code produce different variants:
> 
> 	QVariant v1(QMetaType::QString);
> 	QVariant v2(QVariant::String);
> 
> v1 is a int with value 10 and v2 is a QString with empty content.
> 
> It seems a QVariant constructor that takes a QMetaType::Type is needed.

No, we don't think so.

We ruled that the constructor with a Type and nothing else was a design flaw. 
It creates a null QVariant with a valid type, including types for which null 
isn't possible, like int:

bool isNull(int i)
{
	// what goes here?
}

So it's not a complete replacement. When you're replacing your code, you 
should also fix the above code to be actually meaningful.

-- 
Thiago Macieira - thiago.macieira (AT) intel.com
  Software Architect - Intel Open Source Technology Center
     Intel Sweden AB - Registration Number: 556189-6027
     Knarrarnäsgatan 15, 164 40 Kista, Stockholm, Sweden
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 190 bytes
Desc: This is a digitally signed message part.
URL: <http://lists.qt-project.org/pipermail/development/attachments/20120820/5af6bfd2/attachment.sig>


More information about the Development mailing list