Advertisement
Guest User

Untitled

a guest
Sep 12th, 2018
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  {
  2.        
  3.         QApplication b(argc, argv);
  4.         QRect rec=QApplication::desktop()->screenGeometry();
  5.         qDebug() << rec;
  6.         int height=rec.height();
  7.         int width=rec.width();
  8.  
  9.         float scalefactor=1;
  10.         //calculate scale factor;
  11.         if(height<500) {
  12.             scalefactor=(float)height/480.0*0.85;
  13.         }
  14.         else {
  15.             float maxwidth=(float)width/800.0;
  16.             float maxheight=(float)height/480.0;
  17.  
  18.             if(maxheight>maxwidth)scalefactor=maxwidth;
  19.             else scalefactor=maxheight;
  20.             qDebug() << "Max Height:" << maxheight << "Max Width:" << maxwidth;
  21.             scalefactor=scalefactor*0.95;
  22.  
  23.  
  24.  
  25.         }
  26.         qDebug()<<"Scalefactor" << scalefactor << QString::number(scalefactor,'f',2).toUtf8();
  27.  
  28.         qputenv("QT_SCALE_FACTOR",QString::number(scalefactor,'f',2).toUtf8());
  29.  
  30.     }
  31.  
  32.  
  33.  
  34.     QApplication a(argc, argv);
  35.     a.setAttribute(Qt::AA_EnableHighDpiScaling);
  36.     a.setAttribute(Qt::AA_UseStyleSheetPropagationInWidgetStyles,true);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement