[Interest] Problem with font size on Android and High DPI

Jérôme Godbout godboutj at amotus.ca
Wed Nov 14 18:17:27 CET 2018


Take care the pixel density is way different on a mobile device form a normal desktop window. You might need to adjust your sizing for many thing. I do the following, I develop on a particular device with REFERENCE SIZE:

// Collect screen dimension
        const QScreen* const screen = QGuiApplication::primaryScreen();
        QRect rect = screen->geometry();
        const qreal height = qMax(rect.width(), rect.height());
        const qreal width = qMin(rect.width(), rect.height());
        const qreal dpi = screen->logicalDotsPerInch();

        // Compute reference ratio
        m_horizontal_scale = width / REFERENCE_WIDTH;
        m_vertical_scale = height / REFERENCE_HEIGHT;
        m_dpi_scale = dpi / REFERENCE_DPI;

        // Compute other element scale factor
        m_font_scale = qMin(m_horizontal_scale / m_dpi_scale, m_vertical_scale / m_dpi_scale);

This allow you to have a display that look like each other compare to screen size. It's maybe not what yo are looking for but might give you some idea to achieve what you are looking for.

-----Original Message-----
From: Interest <interest-bounces+godboutj=amotus.ca at qt-project.org> On Behalf Of Roman Wüger
Sent: November 14, 2018 11:30 AM
To: ekke <ekke at ekkes-corner.org>
Cc: interest at qt-project.org
Subject: Re: [Interest] Problem with font size on Android and High DPI

No, it is a QWidget application with Qt 5.12. I can’t switch to QtQuick because customer wants existing application to be ported to android tablet.

Regards
Roman

> Am 14.11.2018 um 17:15 schrieb ekke <ekke at ekkes-corner.org>:
> 
>> Am 14.11.18 um 17:11 schrieb Roman Wüger:
>> Hello everyone,
>> 
>> I enabled the High DPI option on an android tablet. However, the fonts are not resized at all and looks a way too small. I tried the other environment variables too, but the result is not as expected. 
>> 
>> Does anyone have a hint or how is that done normally?
>> 
>> Regards
>> Roman
>> _______________________________________________
>> Interest mailing list
>> Interest at qt-project.org
>> http://lists.qt-project.org/mailman/listinfo/interest
>> 
> what kind of application ?
> 
> QtQuickControls2 ?
> 
> ekke
> 
> _______________________________________________
> Interest mailing list
> Interest at qt-project.org
> http://lists.qt-project.org/mailman/listinfo/interest

_______________________________________________
Interest mailing list
Interest at qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest


More information about the Interest mailing list