0

I cannot figure out how to apply attributes when initialising QApplication. I'm trying to add HighDPI scaling (by changing the attributes of QApplication), but there doesn't appear to be any function for adding attributes. Does it need to be done in command-line with sys.argv? I am using a Qt Designer .ui file for my UI.

What I want is to add is an attribute to the QApplication class hopefully within code. If necessary, I will use command-line.

There appears to be a way in PyQt5, but I'm using PySide2. Checking the documentation shows that there isn't a function for it. Is there a workaround, such as going to QCoreApplication? I have noticed that QCoreApplication does have a function for it, but I'm trying to modify QApplication, a child of QCoreApplication.

Relevant code:

import sys
from PySide2.QtUiTools import QUiLoader
from PySide2.QtWidgets import QApplication
from PySide2.QtCore import QFile, QIODevice

if __name__ == "__main__":
    app = QApplication(sys.argv)
Veritius
  • 39
  • 1
  • 7
  • 1
    Your question is unclear, could you explain what you want to implement in PySide2 – eyllanesc Nov 19 '20 at 00:11
  • If you want to set the attributes as Qt::AA_UseHighDpiPixmaps: `QCoreApplication.setAttribute(Qt.AA_UseHighDpiPixmaps, True)` there is no difference between PyQt5 and PySide2 since they expose the same library. In general there are only small differences – eyllanesc Nov 19 '20 at 00:25
  • Note: The answer does not differentiate if the code was generated from a .ui or other means, the solution is the same. – eyllanesc Nov 19 '20 at 00:28

0 Answers0