[Development] High-dpi Qt best practices
Ziller Eike
Eike.Ziller at digia.com
Tue Oct 9 13:15:12 CEST 2012
On 9 Oct 2012, at 12:50, Sorvig Morten <Morten.Sorvig at digia.com>
wrote:
>
> On Oct 9, 2012, at 12:21 PM, Olivier Goffart <olivier at woboq.com>
> wrote:
>
>> On Tuesday 09 October 2012 09:46:37 Sorvig Morten wrote:
>>> On Oct 9, 2012, at 11:32 AM, Olivier Goffart <olivier at woboq.com>
>>>
>>> wrote:
>>>> But QSize is already the size in pixel.
>>>> Or do you mean that QIcon::pixmap could return a pixmap that is larger
>>>> than
>>>> the given QSize, scaled with some magic heuristics. That is not really
>>>> intuitive. (and violate the current documentation)
>>>
>>> I'm re-defining it to be the size in points. I think this intuitive, you are
>>> asking QIcon::pixmap() for pixmap suitable for covering this many units on
>>> screen - not for a pixmap of a specific size.
>>
>> What is an "unit on screen"? Is it not a pixel?
>
> In this context it is a point - the unit that does not change when you enable high-dpi mode.
>
> Apple has quite comprehensive documentation about this topic: http://tinyurl.com/8me4yzz is recommended background material for those who are interested.
>
>> When you have do QImage(QSize), the image has hight*width pixel, right?
>> Same for QPixmap? or has a pixmap actually more pixal than its size? (as
>> returned by QPixmap::size/width/height)
>
> 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.
It certainly doesn't have a clearly defined mapping to "screen pixels", if you remember this old video :)
Wolfenstein Qt. Qt widgets in a 3D environment
http://www.youtube.com/watch?v=Py_eUAQS1UY
>> I think there should not be that may use of QIcon::pixmap anyway. It is
>> mainly going to be used handled QToolBar and similar.
>
>
> Then it has to work for QToolBar. But I think it's used a fair bit in Qt:
> widgets msorvig$ git grep QIcon | wc
> 668 3666 59429
>
> Morten
>
>
>
>
>
>
> _______________________________________________
> Development mailing list
> Development at qt-project.org
> http://lists.qt-project.org/mailman/listinfo/development
--
Eike Ziller, Senior Software Engineer - Digia, Qt
Digia Germany GmbH, Rudower Chaussee 13, D-12489 Berlin
Geschäftsführer: Mika Pälsi, Juha Varelius, Anja Wasenius
Sitz der Gesellschaft: Berlin, Registergericht: Amtsgericht Charlottenburg, HRB 144331 B
More information about the Development
mailing list