dir
This commit is contained in:
parent
8257285477
commit
a392370132
@ -10,15 +10,18 @@ CONFIG += c++11
|
||||
|
||||
SOURCES += \
|
||||
connect.cpp \
|
||||
directory.cpp \
|
||||
main.cpp \
|
||||
mainwindow.cpp
|
||||
|
||||
HEADERS += \
|
||||
connect.h \
|
||||
directory.h \
|
||||
mainwindow.h
|
||||
|
||||
FORMS += \
|
||||
connect.ui \
|
||||
directory.ui \
|
||||
mainwindow.ui
|
||||
QMAKE_CXXFLAGS += -std=gnu++11
|
||||
# Default rules for deployment.
|
||||
|
@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE QtCreatorProject>
|
||||
<!-- Written by QtCreator 4.14.0, 2021-02-05T01:45:43. -->
|
||||
<!-- Written by QtCreator 4.14.0, 2021-02-06T03:08:00. -->
|
||||
<qtcreator>
|
||||
<data>
|
||||
<variable>EnvironmentId</variable>
|
||||
|
34
directory.cpp
Normal file
34
directory.cpp
Normal file
@ -0,0 +1,34 @@
|
||||
#include "directory.h"
|
||||
#include "ui_directory.h"
|
||||
|
||||
directory::directory(QWidget *parent) :
|
||||
QDialog(parent),
|
||||
ui(new Ui::directory)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
QString sPath = "T:/";
|
||||
dirmodel = new QFileSystemModel(this);
|
||||
dirmodel->setFilter(QDir::NoDotAndDotDot | QDir::AllDirs);
|
||||
dirmodel->setRootPath(sPath);
|
||||
ui->treeView->setModel(dirmodel);
|
||||
|
||||
filemodel = new QFileSystemModel(this);
|
||||
filemodel->setFilter(QDir::NoDotAndDotDot | QDir::AllDirs);
|
||||
filemodel->setRootPath(sPath);
|
||||
|
||||
ui->listView->setModel(filemodel);
|
||||
}
|
||||
|
||||
directory::~directory()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
|
||||
void directory::on_treeView_clicked(const QModelIndex &index)
|
||||
{
|
||||
QString sPath = dirmodel->fileInfo(index).absoluteFilePath();
|
||||
ui->listView->setRootIndex(filemodel->setRootPath(sPath));
|
||||
|
||||
}
|
31
directory.h
Normal file
31
directory.h
Normal file
@ -0,0 +1,31 @@
|
||||
#ifndef DIRECTORY_H
|
||||
#define DIRECTORY_H
|
||||
|
||||
#include <QDialog>
|
||||
#include <QtCore>
|
||||
#include <QtGui>
|
||||
#include <QFileSystemModel>
|
||||
namespace Ui {
|
||||
class directory;
|
||||
}
|
||||
|
||||
class directory : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit directory(QWidget *parent = nullptr);
|
||||
~directory();
|
||||
|
||||
private slots:
|
||||
|
||||
void on_treeView_clicked(const QModelIndex &index);
|
||||
|
||||
private:
|
||||
Ui::directory *ui;
|
||||
QFileSystemModel *dirmodel;
|
||||
QFileSystemModel *filemodel;
|
||||
|
||||
};
|
||||
|
||||
#endif // DIRECTORY_H
|
31
directory.ui
Normal file
31
directory.ui
Normal file
@ -0,0 +1,31 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>directory</class>
|
||||
<widget class="QDialog" name="directory">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>739</width>
|
||||
<height>494</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Dialog</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="0">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QTreeView" name="treeView"/>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QListView" name="listView"/>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
@ -4,6 +4,7 @@
|
||||
#include <QTcpSocket>
|
||||
#include <QTextStream>
|
||||
#include <QString>
|
||||
#include "directory.h"
|
||||
|
||||
MainWindow::MainWindow(QWidget *parent):
|
||||
QMainWindow(parent),
|
||||
@ -14,7 +15,7 @@ MainWindow::MainWindow(QWidget *parent):
|
||||
|
||||
connect(mSocket, &QTcpSocket::readyRead, [&](){
|
||||
QTextStream T(mSocket);
|
||||
auto text = T.readAll();
|
||||
auto text = T.readAll();
|
||||
ui->read->append(text);
|
||||
});
|
||||
|
||||
@ -39,7 +40,9 @@ if(C.exec() == QDialog::Rejected)
|
||||
|
||||
void MainWindow::on_file_clicked()
|
||||
{
|
||||
|
||||
directory d;
|
||||
d.setModal(true);
|
||||
d.exec();
|
||||
}
|
||||
|
||||
void MainWindow::on_send_clicked()
|
||||
|
Loading…
Reference in New Issue
Block a user