問題は、最近 C++ プログラミングを始めたばかりだということです。私の質問は次のとおりです。
mainwindow/treeview で表示されているファイルを実行するにはどうすればよいですか?
表示するドキュメントは、静的パスを持つプレーン テキスト ドキュメントです。sPath は、ファイルが存在するディレクトリへのパスです。
ここに続くのは、私の「mainwindow.cpp」ファイルです。
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include "QDirModel"
#include "QTreeView"
#include "QFileSystemModel"
#include "QtGui"
#include "QtCore"
#include "QDir"
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
QString sPath ="/home/simon/QT Projects/Bra_Programmering/utlatanden/";
filemodel = new QFileSystemModel(this);
filemodel->setFilter(QDir::Files | QDir::NoDotAndDotDot);
filemodel->setNameFilterDisables(false);
filemodel->setRootPath(sPath);
ui->treeView->setModel(filemodel);
ui->treeView->setRootIndex(filemodel->setRootPath(sPath));
}
MainWindow::~MainWindow()
{
delete ui;
}
void MainWindow::on_treeView_doubleClicked(const QModelIndex &index)
{
};
ここに続くのは、私の「mainwindow.h」ファイルです。
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <QMainWindow>
#include <mainwindow.h>
#include <QtCore>
#include <QtGui>
#include <QDirModel>
#include <QFileSystemModel>
namespace Ui {
class MainWindow;
}
class MainWindow : public QMainWindow
{
Q_OBJECT
public:
explicit MainWindow(QWidget *parent = 0);
~MainWindow();
private slots:
void on_treeView_doubleClicked(const QModelIndex &index);
private:
Ui::MainWindow *ui;
QFileSystemModel *filemodel;
};
#endif // MAINWINDOW_H