[Interest] Optimization Request: Function for Applying Scalability in QML

Poonam Sangale sanglepoonam123 at gmail.com
Thu May 18 12:26:28 CEST 2023


Hello,
We have migrated from Qt scalability C++ functions to Singleton QML file
which is responsible for handling scaling operations. The purpose of this
migration was to reduce the number of repeated calls from QML to C++ and
create the component with scaling by default
 However, we encountered a challenge in finding a suitable substitution for
the QGuiApplication::primaryScreen()->logicalDotsPerInch() function in QML.

Please let me know the equivalent in Screen QML component.





On Tue, May 16, 2023 at 7:29 PM Jérôme Godbout <jgodbout at dimonoff.com>
wrote:

> Hi,
>
> Everybody end up doing this in the end. It would be nice if we could
> intercept the width/height on an object by extension to scale it
> automatically.
>
>
>
> Item
>
> {
>
>
>
>    DpiScaler on height {}
>
>    DpiScaler on width {}
>
> }
>
>
>
> And avoid those complex binding assignations. Not sure it would make sense
> or would be possible but that could be nice to have that component with the
> initialization by default with the dpi scaling on that axis.
>
>
>
> Just an idea out of my hat.
>
>
>
>
>
> *From: *Interest <interest-bounces at qt-project.org> on behalf of Poonam
> Sangale <sanglepoonam123 at gmail.com>
> *Date: *Tuesday, May 16, 2023 at 6:19 AM
> *To: *Interest at qt-project.org <Interest at qt-project.org>
> *Subject: *[Interest] Optimization Request: Function for Applying
> Scalability in QML
>
> I hope this email finds you well. I am writing to discuss a function that
> we are currently using in our QML codebase to apply scalability. While the
> function serves its purpose, we have identified some areas where it can be
> optimized to avoid multiple function calls from C++.
>
> Our goal is to reduce the repetitive function calls made from C++ to
> enhance the performance of our application
>
>
>
> "theme.h" Theme::Theme() { refDpi = 96.; refHeight = 600.; refWidth =
> 1024.; rect = QGuiApplication::primaryScreen()->geometry(); qDebug()<<rect;
> height = rect.height(); width = rect.width(); dpi =
> QGuiApplication::primaryScreen()->logicalDotsPerInch(); qDebug()<<dpi;
> m_hratio = height/refHeight; m_wratio = width/refWidth; m_ratioFont =
> qMin(height*refDpi/(dpi*refHeight), width*refDpi/(dpi*refWidth)); } int
> Theme::applyFontRatio(const int value) { return int(value * m_ratioFont); }
> int Theme::applyHeightRatio(const int value) { return qMax(2, int(value *
> m_hratio)); } int Theme::applyWidthRatio(const int value) { return qMax(2,
> int(value * m_wratio)); }
>
>
>
> main.qml import QtQuick 2.15 import QtQuick.Window 2.15 import
> QtQuick.Controls 2.5 import QtQuick.Layouts 1.3 ApplicationWindow {
> id:mainWindow width: owner.applyWidthRatio(909,"Width for Region3(register
> page)") height: owner.applyHeightRatio(802,"Width for Region3(register
> page)") visible: true
>
> }
>
>
>
> Thanks,
>
> Poonam
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20230518/228b8228/attachment.htm>


More information about the Interest mailing list