点击按钮,打开文本对话框,找一人文件,打开并显示内容                                                                                                                                                                                     

                                                                                                                                                                                              QFIleDialog

pyqt5通过文本对话框打开文件                                                                 pyqt5通过文本对话框打开文件

def openfile(self):
    filename,_ = QFileDialog.getOpenFileName(self);
    text=open(filename,'r').read()
    self.textEdit.setText(text)

我用QFile,QTextStream,QIODevice做了半天也没做出来,改用python自带的文件操作命令做了出来。

相关文章:

  • 2022-02-06
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-02-03
  • 2021-07-03
  • 2022-12-23
  • 2021-11-24
相关资源
相似解决方案