[Interest] QDatastream, QMap, QImage serialization

Jason H jhihn at gmx.com
Tue May 22 15:38:46 CEST 2018



> Sent: Monday, May 21, 2018 at 4:02 PM
> From: "Thiago Macieira" <thiago.macieira at intel.com>
> To: interest at qt-project.org
> Subject: Re: [Interest] QDatastream, QMap, QImage serialization
>
> On Monday, 21 May 2018 15:50:02 -03 Jason H wrote:
> > I don't think C++ has a good concept of what it is that I want to do. C++
> > does not allow multiple return types from functions, therefore, the only
> > way to get the type you want returned is provide an overload with different
> > parameters.  What is needed is something "orthogonal" to an enum. Whereas
> > enums are all the same type, you need a thing that is the same "thing" but
> > different type. You can't use enums names because it's too easy to convert
> > between them since they are all ints under the hood.
> > 
> > class QPixmapAtom {};
> > class QImageAtom {};
> > class QBrush {
> > ...
> >     QPixmap texture(QPixmapAtom());
> >     QImage texture(QImageAtom());
> > };
> 
> How about just using different function names instead? Like, you know, 
> "texture" and "textureImage"?

How about texture() and texturePixmap()? There is a difference. As you already stated, a QPixmap requires more than a QImage, so what should be provided is a QImage, which then can be converted with QPixmap::fromImage();. If we want to move QImage out of GUI, then dropping the pixmap function would help. Would it not?







More information about the Interest mailing list