Skip to content Skip to sidebar Skip to footer

QFileDialog Closes Window When Called

This if my first time asking a question here so please forgive me for any mistakes. So my problem is when I run my program it works fine. But as soon as I click Search the program

Solution 1:

You are using the keyword self from a non-member function. Just put the function in your class:

def run(self):
    openfile = QtWidgets.QFileDialog.getOpenFileName() # Filename line
    f = open(openfile[0], 'r') # New line
    data = f.read()

an connect it with:

self.pushButton_5.cicked.connect(self.run)

Post a Comment for "QFileDialog Closes Window When Called"