[Development] High-dpi Qt best practices

Samuel Rødal samuel.rodal at digia.com
Tue Oct 9 14:49:52 CEST 2012


On 10/09/2012 01:53 PM, Olivier Goffart wrote:
> On Tuesday 09 October 2012 10:50:26 Sorvig Morten wrote:
>> On Oct 9, 2012, at 12:21 PM, Olivier Goffart <olivier at woboq.com>
>> Pixmaps and images _always_ have exactly QPixmap::size() pixels.
>>
>>> Maybe we can introduce QSizePt
>>> Code would look like
>>> QPixmap p = QIcon::pixmap(QSizePt(20,20).toSize(window));
>>> (but then again, i'd say it is bad practice to even hardcode pt size)
>>
>> I don't know.. to me QSize is just a pair of ints, it does not have a unit.
>
> We use QSize and not QPoint or QPair<int,int>  to take advantage of the C++
> type system.  I have the impression that QSize is used everywhere else in
> pixel. Or do you have an example where it is not?

Here's an example :)

painter->fillRect(QRect(QPoint(0, 0), QSize(10, 10)), Qt::yellow);

The size denotes logical or object space coordinates here, not device 
pixels, since the painter might have any kind of scale or even 
perspective transform set.

--
Samuel



More information about the Development mailing list