Unsolved QFileDialog is not scaled the same way as the QApplicaiton with high DPI monitor
I am developing an application to work with 4k monitor. I manged to get nicely scaled application with Qt5.14.2 with following code:
QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling); QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); QGuiApplication::setHighDpiScaleFactorRoundingPolicy(Qt::HighDpiScaleFactorRoundingPolicy::Ceil);
However when I open a file dialog using QFileDialog::getOpenFileNames, the pop-up dialog looks a lot smaller. I even tried the following code to make sure it has the same font size as the whole application, but the resultant pop up still looks the same same:
QFileDialog openFileDialog; QFont font = QApplication::font(); font.setPointSize(8); openFileDialog.setFont(font);
Any idea why this is happening and how to fix it?
This is a static method, changing font on a QFileDialog instance will not influence what getOpenFileNames shows.
@jsulm any clue how to fix this issue?
@johnyang You could try to pass QFileDialog::DontUseNativeDialog as options to QFileDialog::getOpenFileNames
@jsulm Looks like that is the only way to get the scaled widget correctly. Thanks!