[Development] High-dpi Qt best practices

Ziller Eike Eike.Ziller at digia.com
Thu Oct 11 08:23:29 CEST 2012


On 10.10.2012, at 16:56, Olivier Goffart wrote:

What is wrong with this alternative:

All the API stays always in pixel  (QIcon, QWidget::geometry, ...)

QCoreApplication::setAttribute(Qt::AA_MacHighDPI)
(should it maybe be even be set by default?)

Setting it as default would make it impossible to just run an application

If that is set, everything is in pixel, but the default font size is twice as
big, the mac style returns pixelmetrics ans sizes that are twice as big, and
all the widgets are then automatically twice as big

In general, that's the way to do it.

Having hardcoded pixel value has always
been a bad practice with Qt.

* it's a reality
* in painting code there is just no other way

So, that would mean spreading factors round all of the code.

Application that did it will possibly look bad on high-res display and will
need to be fixed.  But I think they will need the same amount of fixes with
the other appreach because sometimes they really mean pixel, sometimes they
mean point.

You should have a look at Qt Creator in HiDPI *as it is now*. Without any special high resolution code. Basically the only problem is that any part that is based on images in there looks bad compared to the rest. I believe that for most applications solving that problem, high resolution images, is the only need.

If you'd now be able to change the unit in Qt to "pixel metrics" for certain widgets (and optionally sub widgets) where you really want to take advantage of each and every pixel in e.g. painting code, then every case would be covered. (And you could decide to do what you suggest.)

The only thing is about QPen. should we draw lines twice as large?  that is
bascically what QPen::isCosmetic is for.

--
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

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/development/attachments/20121011/dd82fef7/attachment.html>


More information about the Development mailing list