高分辨率屏幕上的 PyQt GUI 大小 [英] PyQt GUI size on high resolution screens

查看:46
本文介绍了高分辨率屏幕上的 PyQt GUI 大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不久前发布了一个

解决方案

在应用加载前,而不是在加载时.

插入:

if hasattr(QtCore.Qt, 'AA_EnableHighDpiScaling'):PyQt5.QtWidgets.QApplication.setAttribute(QtCore.Qt.AA_EnableHighDpiScaling, True)如果 hasattr(QtCore.Qt, 'AA_UseHighDpiPixmaps'):PyQt5.QtWidgets.QApplication.setAttribute(QtCore.Qt.AA_UseHighDpiPixmaps, True)

像这样:

导入 PyQt5从 PyQt5 导入 QtCore、QtGui、uic、QtWidgets从 PyQt5.QtWidgets 导入 QWidget如果 hasattr(QtCore.Qt, 'AA_EnableHighDpiScaling'):PyQt5.QtWidgets.QApplication.setAttribute(QtCore.Qt.AA_EnableHighDpiScaling, True)如果 hasattr(QtCore.Qt, 'AA_UseHighDpiPixmaps'):PyQt5.QtWidgets.QApplication.setAttribute(QtCore.Qt.AA_UseHighDpiPixmaps, True)类 MyWindow(PyQt5.QtWidgets.QMainWindow):def __init__(self):super(MyWindow, self).__init__()

如果这仍然不起作用,请在 user en var 中,而不是在 system en var 中.

QT_AUTO_SCREEN_SCALE_FACTOR=2

qt-5/highdpi

I posted a question a while ago asking about Tkinter backends and subsequently forgot about it but I've since realised that I'm using the pyqt backend. Is there a fix for that?

Original Question:

So it appears that matplotlib gui plots (a la plt.show()) don't adapt to monitor resolution and appear tiny on high resolution screens. Is there a matplotlib+Pyqt fix or do I have fiddle around somewhere in Windows settings?

Thanks

解决方案

Before app is loaded, and not while loading.

insert:

if hasattr(QtCore.Qt, 'AA_EnableHighDpiScaling'):
    PyQt5.QtWidgets.QApplication.setAttribute(QtCore.Qt.AA_EnableHighDpiScaling, True)

if hasattr(QtCore.Qt, 'AA_UseHighDpiPixmaps'):
    PyQt5.QtWidgets.QApplication.setAttribute(QtCore.Qt.AA_UseHighDpiPixmaps, True)

like so :

import PyQt5
from PyQt5 import QtCore, QtGui, uic, QtWidgets
from PyQt5.QtWidgets import QWidget

if hasattr(QtCore.Qt, 'AA_EnableHighDpiScaling'):
    PyQt5.QtWidgets.QApplication.setAttribute(QtCore.Qt.AA_EnableHighDpiScaling, True)

if hasattr(QtCore.Qt, 'AA_UseHighDpiPixmaps'):
    PyQt5.QtWidgets.QApplication.setAttribute(QtCore.Qt.AA_UseHighDpiPixmaps, True)


class MyWindow(PyQt5.QtWidgets.QMainWindow):
    def __init__(self):
        super(MyWindow, self).__init__()

And if that still don't work, in user en var and not system en var.

QT_AUTO_SCREEN_SCALE_FACTOR=2 

qt-5/highdpi

这篇关于高分辨率屏幕上的 PyQt GUI 大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆