[Interest] How to read screen information from QGuiApplication to put in qputenv environment variable?

Giuseppe D'Angelo giuseppe.dangelo at kdab.com
Mon Feb 15 13:16:54 CET 2021


Il 15/02/21 12:50, Anisha kaul ha scritto:
> |qreal abc = QGuiApplication::primaryScreen()->physicalDotsPerInch(); 
> qDebug() << "null " << abc; qputenv("QT_SCALE_FACTOR", "2"); 
> QGuiApplication app(argc, argv);|

I'm not exactly sure why would you want to do this, but you can destroy 
and recreate the QGuiApplication object.

The only annoying part is that you'll need to copy the command line 
arguments. Ignoring that issue for now:


int main(int argc, char **argv) {
   {
      QGuiApplication app(argc, argv);
      // access screen info, calculate scaling, etc.
      // qputenv
   }

   // app destroyed , recreate it

   QGuiApplication app(argc, argv);

   // rest of main

}


My 2 c,
-- 
Giuseppe D'Angelo | giuseppe.dangelo at kdab.com | Senior Software Engineer
KDAB (France) S.A.S., a KDAB Group company
Tel. France +33 (0)4 90 84 08 53, http://www.kdab.com
KDAB - The Qt, C++ and OpenGL Experts

-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 4329 bytes
Desc: Firma crittografica S/MIME
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20210215/412cc5f0/attachment.bin>


More information about the Interest mailing list