zoukankan      html  css  js  c++  java
  • QFileDialog的使用

    void FileDialog::SelectFile()
    {
      QString path = QDir::currentPath();
      //filepathname返回文件路径+名字
      /*
      getExistingDirectory:选取目录
      getOpenFileNames:可以选择多个或者单个文件
      */
      QString filepathname = QFileDialog::getOpenFileName(this,
                             u8"选择需要打开的文件", path, "text files (*.txt)");
      QFileInfo fi = QFileInfo(filepathname);
      //获取文件名字
      QString filename = fi.fileName();
      //获取文件目录,不包括文件名字
      QString dirname = fi.dir().path();
      ui.filename_edit->setText(filename);
      ui.filepath_edit->setText(dirname);
    }

    界面如下:

     软件源码:https://github.com/Mr-jiayunfei/qt_code.git

  • 相关阅读:
    Nginx 跨域配置支持
    数据结构与算法分析
    数据结构与算法分析
    数据结构与算法分析
    Bash shell
    Bash shell
    HHUOJ 1040
    HHUOJ 1114
    HDUOJ 1171
    HDUOJ 1428
  • 原文地址:https://www.cnblogs.com/LuckCoder/p/11429801.html
Copyright © 2011-2022 走看看