qtでカレントパスを取得するには?
現在のパスを取得するには、QCoreApplication::applicationDirPath()メソッドを使用します。このメソッドは、アプリケーションの現在のパスを示すQStringを返します。以下にサンプルコードを示します。
#include <QCoreApplication>
#include <QDebug>
int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);
QString currentPath = QCoreApplication::applicationDirPath();
qDebug() << "Current path: " << currentPath;
return a.exec();
}
このコードを実行すると、カレントディレクトリが出力されます。