dir
This commit is contained in:
parent
8257285477
commit
a392370132
@ -10,15 +10,18 @@ CONFIG += c++11
|
|||||||
|
|
||||||
SOURCES += \
|
SOURCES += \
|
||||||
connect.cpp \
|
connect.cpp \
|
||||||
|
directory.cpp \
|
||||||
main.cpp \
|
main.cpp \
|
||||||
mainwindow.cpp
|
mainwindow.cpp
|
||||||
|
|
||||||
HEADERS += \
|
HEADERS += \
|
||||||
connect.h \
|
connect.h \
|
||||||
|
directory.h \
|
||||||
mainwindow.h
|
mainwindow.h
|
||||||
|
|
||||||
FORMS += \
|
FORMS += \
|
||||||
connect.ui \
|
connect.ui \
|
||||||
|
directory.ui \
|
||||||
mainwindow.ui
|
mainwindow.ui
|
||||||
QMAKE_CXXFLAGS += -std=gnu++11
|
QMAKE_CXXFLAGS += -std=gnu++11
|
||||||
# Default rules for deployment.
|
# Default rules for deployment.
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<!DOCTYPE QtCreatorProject>
|
<!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>
|
<qtcreator>
|
||||||
<data>
|
<data>
|
||||||
<variable>EnvironmentId</variable>
|
<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 <QTcpSocket>
|
||||||
#include <QTextStream>
|
#include <QTextStream>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
|
#include "directory.h"
|
||||||
|
|
||||||
MainWindow::MainWindow(QWidget *parent):
|
MainWindow::MainWindow(QWidget *parent):
|
||||||
QMainWindow(parent),
|
QMainWindow(parent),
|
||||||
@ -14,7 +15,7 @@ MainWindow::MainWindow(QWidget *parent):
|
|||||||
|
|
||||||
connect(mSocket, &QTcpSocket::readyRead, [&](){
|
connect(mSocket, &QTcpSocket::readyRead, [&](){
|
||||||
QTextStream T(mSocket);
|
QTextStream T(mSocket);
|
||||||
auto text = T.readAll();
|
auto text = T.readAll();
|
||||||
ui->read->append(text);
|
ui->read->append(text);
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -39,7 +40,9 @@ if(C.exec() == QDialog::Rejected)
|
|||||||
|
|
||||||
void MainWindow::on_file_clicked()
|
void MainWindow::on_file_clicked()
|
||||||
{
|
{
|
||||||
|
directory d;
|
||||||
|
d.setModal(true);
|
||||||
|
d.exec();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::on_send_clicked()
|
void MainWindow::on_send_clicked()
|
||||||
|
Loading…
Reference in New Issue
Block a user