Quantcast
Channel: Active questions tagged python - Stack Overflow
Viewing all articles
Browse latest Browse all 13891

How to select app-execution reparse points in QFileDialog

$
0
0

When I select a reparse point from %LocalAppData%\Microsoft\WindowsApps (e.g. julia.exe) using a QFileDialog and click the Open button an error dialog pops up

Error dialog

Clicking Ok just closes the error dialog but doesn't close the file browser window.

Here's a minimal example that demonstrates the problem. Click the Browse button and select any .exe file from %LocalAppData%\Microsoft\WindowsApps and the error dialog pops up.

from PySide6.QtWidgets import QApplication, QDialog, QPushButton, QFileDialog, QLineEdit, QVBoxLayoutclass Main(QDialog):    def __init__(self):        super().__init__()        self.button = QPushButton("Browse")        self.le = QLineEdit()        self.lo = QVBoxLayout()        self.lo.addWidget(self.button)        self.lo.addWidget(self.le)        self.setLayout(self.lo)        self.button.clicked.connect(self.open_browser)    def open_browser(self):        self.le.clear()        answer = QFileDialog.getOpenFileName(self, "Open")        if answer[0] != "":            self.le.setText(answer[0])        returnif __name__ == '__main__':    app = QApplication()    window = Main()    window.show()    app.exec()

I'm aware that %LocalAppData%\Microsoft\WindowsApps is in PATH and I do not actually need to select the reparse point file anyway but this is an error dialog that some users of my app may encounter and I'd like to deal with it somehow.

The question is, how can I select the reparse point file and then return it from the QFileDialog? Is there a way to catch the error that causes the error dialog to pop up and then simply return the full path as the answer in the above code snippet?

Win: 10
Python: 3.10.8
PySide6: 6.5.2

Things tried & considered:

  • Tried using the QFileDialog constructor directly and calling open() to show the dialog but the result is the same.
  • Tried catching the error in a Slot for the QDialog.accepted signal but this is triggered too late. The error dialog pops up before the Slot is processed.
  • Using option (QFileDialog::DontResolveSymlinks) did not help. Same error dialog pops up.
  • Considered using Qt's own file browser (QFileDialog::DontUseNativeDialog). I don't want to do this because the Windows users of my app are accustomed to their native file browser.

Viewing all articles
Browse latest Browse all 13891

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>