Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- {
- QApplication b(argc, argv);
- QRect rec=QApplication::desktop()->screenGeometry();
- qDebug() << rec;
- int height=rec.height();
- int width=rec.width();
- float scalefactor=1;
- //calculate scale factor;
- if(height<500) {
- scalefactor=(float)height/480.0*0.85;
- }
- else {
- float maxwidth=(float)width/800.0;
- float maxheight=(float)height/480.0;
- if(maxheight>maxwidth)scalefactor=maxwidth;
- else scalefactor=maxheight;
- qDebug() << "Max Height:" << maxheight << "Max Width:" << maxwidth;
- scalefactor=scalefactor*0.95;
- }
- qDebug()<<"Scalefactor" << scalefactor << QString::number(scalefactor,'f',2).toUtf8();
- qputenv("QT_SCALE_FACTOR",QString::number(scalefactor,'f',2).toUtf8());
- }
- QApplication a(argc, argv);
- a.setAttribute(Qt::AA_EnableHighDpiScaling);
- a.setAttribute(Qt::AA_UseStyleSheetPropagationInWidgetStyles,true);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement