ファイル選択ボタンを設置し、ファイル名を取得する。
QrCreatorで画面を作成、ファイル選択ボタン(オブジェクト名:FileButton)のクリックスロット(on_FileButton_clicked())に、以下のコードを設定しています。
環境:QT5.5
リンク
http://doc.qt.io/qt-5/qfiledialog.html
http://doc.qt.io/qt-5/qstandardpaths.html
インクルードファイル
#include
#include
コード
// ファイル選択ダイアログを起動、指定されたファイル名を取得
strFileName = QFileDialog::getOpenFileName(this, tr("ファイル選択画面"), QStandardPaths::writableLocation(QStandardPaths::DesktopLocation));
コメント