資源簡介
QT文件資源管理器

代碼片段和文件信息
#include?“filemanager.h“
#include?
#include?
#include?
#include?
#include?
#include?
//構造函數
FileManager::FileManager(QWidget?*parent)
????:?QWidget(parent)
{
????QLabel?*pathLabel?=?new?QLabel(this);
????pathLabel->setText(tr(“path“));
????initSystem();
????connect(treeView?SIGNAL(doubleClicked(QModelIndex?))?table?SLOT(setRootIndex(QModelIndex?)));
????connect(table?SIGNAL(doubleClicked(QModelIndex?))?thisSLOT(showChild(QModelIndex)));
????connect(treeView?SIGNAL(doubleClicked(QModelIndex?))thisSLOT(showPath(QModelIndex)));
????connect(table?SIGNAL(doubleClicked(QModelIndex?))?thisSLOT(showPath(QModelIndex)));
????connect(backPtnSIGNAL(clicked())SLOT(GoBack()));
????connect(advancePtnSIGNAL(clicked())SLOT(GoAhead()));
????connect(tableSIGNAL(clicked(QModelIndex))thisSLOT(getPath(QModelIndex)));
????QSplitter?*splitter?=?new?QSplitter(this);
????splitter->addWidget(treeView);
????splitter->addWidget(table);
????splitter->show();
????QHBoxLayout?*hlayout?=?new?QHBoxLayout;
????QVBoxLayout?*vlayout?=?new?QVBoxLayout;
????hlayout->addWidget(advancePtn);
????hlayout->addWidget(backPtn);
????hlayout->addWidget(pathLabel);
????hlayout->addWidget(pathLine);
????vlayout->addLayout(hlayout);
????vlayout->addWidget(splitter);
????setLayout(vlayout);
}
//析構函數
FileManager::~FileManager()
{
????delete?model;
????delete?treeView;
????delete?table;
????delete?pathLine;
????delete?backPtn;
????delete?advancePtn;
}
//新建文本文檔
void?FileManager::newTxtFile(void)
{
????QString?path?=?model->fileInfo(DirIndex).absoluteFilePath();//獲取程序當前文件路徑
#ifdef?_WIN32
????path.replace(“/““\\“);//將路徑中的‘/‘替換為windows中的‘\\‘
????path?=?path?+?“\\“;
#else
????path?=?path?+?“/“;//LINUX路徑
#endif
????if(!findSameFile(tr(“NewNotepad.txt“)path))
????{
????????QFile?file(path+tr(“NewNotepad.txt“));
????????file.open(QIODevice::WriteOnly);
????????file.close();
????}
????else
????{
????????int?i?=?1;
????????QString?num;
????????while(1)
????????{
????????????QString?filename?=?tr(“NewNotepad“)+num.setNum(i)+“.txt“;
????????????if(!findSameFile(filenamepath))
????????????{
????????????????QFile?file(path+filename);
????????????????file.open(QIODevice::WriteOnly);
????????????????file.close();
????????????????return;
????????????}
????????????i++;
????????}
????}
}
//新建excel表格
void?FileManager::newExelFile(void)
{
????QString?path?=?model->fileInfo(DirIndex).absoluteFilePath();//獲取程序當前文件路徑
#ifdef?_WIN32
????path.replace(“/““\\“);//將路徑中的‘/‘替換為windows中的‘\\‘
????path?=?path?+?“\\“;
#else
????path?=?path?+?“/“;
#endif
????if(!findSameFile(tr(“Microsoft?Excel.xls“)path))
????{
????????QFile?file(path+tr(“Microsoft?Excel.xls“));
????????file.open(QIODevice::WriteOnly);
????????file.close();
????}
????else
????{
????????int?i?=?1;
????????QString?num;
????????while(1)
????????{
????????????QStrin
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件??????16791??2015-12-10?15:16??fileManager_Qt\filemanager.cpp
?????文件???????1586??2015-12-10?09:55??fileManager_Qt\filemanager.h
?????文件????????192??2015-12-10?10:29??fileManager_Qt\FileManager.pro
?????文件????????129??2012-12-24?22:28??fileManager_Qt\icon.qrc
?????文件??????23935??2012-12-24?22:18??fileManager_Qt\images\back.png
?????文件??????23910??2012-12-24?22:18??fileManager_Qt\images\go.png
?????文件???????1089??2015-12-10?11:38??fileManager_Qt\main.cpp
?????目錄??????????0??2018-12-27?18:49??fileManager_Qt\images
?????目錄??????????0??2018-12-27?18:49??fileManager_Qt
-----------?---------??----------?-----??----
????????????????67632????????????????????9
- 上一篇:KWIC體系結構風格與模式
- 下一篇:基于STC89C52RC的超聲波測距系統設計
評論
共有 條評論