Op 17/04/2017 om 08:02 schreef Jason H: > Maybe templates are the way to go. But I just had to change some lines > because I was using vectors and Qt was using QList. I'd like to eliminate the > need/cost for QList::toVector() and QVector::toList(). If there was a base > that provided the basics so that I don't have to worry about it's > representation in my code, I want the developer (usually me, but anyone using > my functions) to be the one that makes that decision. Well, I think most people here would agree QList was not the best choice in retrospect. > > You're right I don't know how C++ handles virtuals, but should I care? This > is OOP, I want to use OOP. You're telling me that because the > language/compiler implements something poorly, that I can't use OOP? There are many people for who real-world performance means a lot more that your wish to use "OOP" - for whatever understanding you have of that concept. Still, I'd like to see your proposal to to consolidate QRect and QRectF into one hierarchy using that. I don't see that working out, but perhaps I am missing something. What would the width() method return, for instance?
André > > >> Sent: Sunday, April 16, 2017 at 11:44 PM >> From: "Thiago Macieira" <[email protected]> >> To: [email protected] >> Subject: Re: [Development] Lack of base classes/interfaces? Q*, Q*F >> >> Em domingo, 16 de abril de 2017, às 18:25:49 PDT, Jason H escreveu: >>> I am wondering why all the Q* and Q*F classes (where $1 in [Rect, Point, >>> etc]) don't use an interface? I recently moved some code from ints to >>> floats, and I had to change far more code than I should have had to. >> If you're thinking of a template class and make each of those just an >> instantiation of the template, it could be done, and yet wouldn't help you a >> lot. Each instantiation is a distinct type. Your code would need to be >> adapted. >> >> It wouldn't be easy for us either, as the algorithms are subtly different. >> The >> rectangle and size, for example, store the inclusive bottom-right >> coordinate, >> whereas the floating point ones store them exclusive. >> >> If you're thinking of base class with inheritance and virtuals, then you >> have >> to learn a lot about C++ efficiency. Those classes are too small for >> virtuals. >> It would be bad API design and an incredible overhead for little gain. As I >> mentioned, the classes have actually little in common between one another. >> >>> My proposal is to change QRect to QRectI, and make QRect an interface. >> That's a vague suggestion. Make a concrete proposal, please. Without >> virtuals, >> of course. >> >>> I'm not fan of MS's Ieverything, but I think base classes/interfaces are >>> under used in Qt. Why aren't there more of them? >> You are thinking of classes with virtuals. QRect has no virtuals and shall >> never have them. >> >> -- >> Thiago Macieira - thiago.macieira (AT) intel.com >> Software Architect - Intel Open Source Technology Center >> >> _______________________________________________ >> Development mailing list >> [email protected] >> http://lists.qt-project.org/mailman/listinfo/development >> > _______________________________________________ > Development mailing list > [email protected] > http://lists.qt-project.org/mailman/listinfo/development _______________________________________________ Development mailing list [email protected] http://lists.qt-project.org/mailman/listinfo/development
