Qt文件和目录相关操作

1.相关说明

QCoreApplication类、QFile类、QDir、QTemporaryDir类、QTemporaryFile类、QFileSystemWatcher类的相关函数

2.相关界面

3.相关代码

#include "dialog.h"
#include "ui_dialog.h"
#include <QFileDialog>
#include <QTemporaryDir>
#include <QTemporaryFile>
#include <QFileSystemWatcher>Dialog::Dialog(QWidget *parent): QDialog(parent), ui(new Ui::Dialog)
{ui->setupUi(this);fileWatcher = NULL;
}Dialog::~Dialog()
{delete ui;
}// 打开一个文件
void Dialog::on_btnOpenFile_clicked()
{QString curDir = QCoreApplication::applicationDirPath();QString aFile = QFileDialog::getOpenFileName(this, "打开一个文件", curDir, "(*.cpp *.h *.c);;(*.*)");ui->lineEditFile->setText(aFile);
}
// 打开一个目录
void Dialog::on_btnOpenDir_clicked()
{QString curDir = QCoreApplication::applicationDirPath();QString aDir = QFileDialog::getExistingDirectory(this, "选择一个目录", curDir);ui->lineEditDir->setText(aDir);
}
// 清除文本框
void Dialog::on_btnClear_clicked()
{ui->plainTextEdit->clear();
}void Dialog::showBtnInfo(QObject *btn)
{QPushButton *theBtn = static_cast<QPushButton*>(btn);ui->plainTextEdit->appendPlainText(theBtn->text());ui->plainTextEdit->appendPlainText(theBtn->toolTip()+":");
}// applicationDirPath()
void Dialog::on_btnApplicationDirPath_clicked()
{showBtnInfo(sender());QString str = QCoreApplication::applicationDirPath();ui->plainTextEdit->appendPlainText(str);
}
// applicationFilePath()
void Dialog::on_btnApplicationFilePath_clicked()
{showBtnInfo(sender());QString str = QCoreApplication::applicationFilePath();ui->plainTextEdit->appendPlainText(str);
}
// applicationName()
void Dialog::on_btnApplicationName_clicked()
{showBtnInfo(sender());// QCoreApplication::setApplicationName("My App");QString str = QCoreApplication::applicationName();ui->plainTextEdit->appendPlainText(str);
}
// setApplicationName(QString)
void Dialog::on_btnSetApplicationName_clicked()
{showBtnInfo(sender());QCoreApplication::setApplicationName("My App");QString str = QCoreApplication::applicationName();ui->plainTextEdit->appendPlainText(str);
}
// libraryPaths()
void Dialog::on_btnLibraryPaths_clicked()
{showBtnInfo(sender());QStringList paths = QCoreApplication::libraryPaths();for(auto &path : paths){ui->plainTextEdit->appendPlainText(path);}
}
// organizationName()
void Dialog::on_btnOrganiazationName_clicked()
{showBtnInfo(sender());QCoreApplication::setOrganizationName("My Organization");QString orgName = QCoreApplication::organizationName();ui->plainTextEdit->appendPlainText(orgName);
}
// exit()
void Dialog::on_btnExit_clicked()
{QCoreApplication::exit();
}
// QFile::copy
void Dialog::on_btnQFileCopy_clicked()
{showBtnInfo(sender());QString sourceFile = ui->lineEditFile->text();QFileInfo fileInfo(sourceFile);QString newFile = fileInfo.path()+"/"+fileInfo.baseName()+"--副本."+fileInfo.suffix();QFile::copy(sourceFile, newFile);ui->plainTextEdit->appendPlainText("源文件:"+sourceFile);ui->plainTextEdit->appendPlainText("副本:"+newFile);
}
// QFile::exists
void Dialog::on_btnQFileExists_clicked()
{showBtnInfo(sender());QString sourceFile = ui->lineEditFile->text();if(QFile::exists(sourceFile)){ui->plainTextEdit->appendPlainText(sourceFile + ":存在");} else {ui->plainTextEdit->appendPlainText(sourceFile + ":不存在");}}
// QFile::remove
void Dialog::on_btnRemove_clicked()
{showBtnInfo(sender());QString sourceFile = ui->lineEditFile->text();if(QFile::remove(sourceFile)){ui->plainTextEdit->appendPlainText("remove "+sourceFile+" 成功");} else {ui->plainTextEdit->appendPlainText("remove "+sourceFile+" 失败");}
}
// QFile::rename
void Dialog::on_btnQFileRename_clicked()
{showBtnInfo(sender());QString sourceFile = ui->lineEditFile->text();QFileInfo fileInfo(sourceFile);QString newFile = fileInfo.path()+"/"+fileInfo.baseName()+"--新名称."+fileInfo.suffix();if(QFile::rename(sourceFile, newFile)){ui->plainTextEdit->appendPlainText("旧名称:"+sourceFile);ui->plainTextEdit->appendPlainText("新名称:"+newFile);} else {ui->plainTextEdit->appendPlainText("修改 "+sourceFile+" 失败");}
}
// QFile::moveToTrash
void Dialog::on_btnQFileMoveToTrash_clicked()
{showBtnInfo(sender());QString sourceFile = ui->lineEditFile->text();if(QFile::exists(sourceFile) && QFile::moveToTrash(sourceFile)){ui->plainTextEdit->appendPlainText("删除文件到垃圾箱:"+sourceFile);} else {ui->plainTextEdit->appendPlainText("文件不存在");}
}
// file.copy
void Dialog::on_btnCopy_clicked()
{showBtnInfo(sender());QString sourceFile = ui->lineEditFile->text();QFileInfo fileInfo(sourceFile);QString newFile = fileInfo.path()+"/"+fileInfo.baseName()+"--副本."+fileInfo.suffix();QFile file(sourceFile);// QFile::copy(sourceFile, newFile);if(file.copy(newFile)){ui->plainTextEdit->appendPlainText("源文件:"+sourceFile);ui->plainTextEdit->appendPlainText("副本:"+newFile);} else {ui->plainTextEdit->appendPlainText("复制文件失败:"+sourceFile);}}
// file.exists
void Dialog::on_btnExists_clicked()
{showBtnInfo(sender());QString sourceFile = ui->lineEditFile->text();QFile file(sourceFile);if(file.exists()){ui->plainTextEdit->appendPlainText(sourceFile + ":存在");} else {ui->plainTextEdit->appendPlainText(sourceFile + ":不存在");}
}
// file.remove
void Dialog::on_btnRemove_2_clicked()
{showBtnInfo(sender());QString sourceFile = ui->lineEditFile->text();QFile file(sourceFile);if(file.remove()){ui->plainTextEdit->appendPlainText("remove "+sourceFile+" 成功");} else {ui->plainTextEdit->appendPlainText("remove "+sourceFile+" 失败");}
}
// file.rename
void Dialog::on_btnRename_clicked()
{showBtnInfo(sender());QString sourceFile = ui->lineEditFile->text();QFileInfo fileInfo(sourceFile);QString newFile = fileInfo.path()+"/"+fileInfo.baseName()+"--新名称."+fileInfo.suffix();QFile file(sourceFile);if(file.rename(newFile)){ui->plainTextEdit->appendPlainText("旧名称:"+sourceFile);ui->plainTextEdit->appendPlainText("新名称:"+newFile);} else {ui->plainTextEdit->appendPlainText("修改 "+sourceFile+" 失败");}
}
// file.moveToTrash
void Dialog::on_btnMoveToTrash_clicked()
{showBtnInfo(sender());QString sourceFile = ui->lineEditFile->text();QFile file(sourceFile);if(file.exists() && file.moveToTrash()){ui->plainTextEdit->appendPlainText("删除文件到垃圾箱:"+sourceFile);} else {ui->plainTextEdit->appendPlainText("文件不存在");}
}
// absoluteFilePath()
void Dialog::on_btnAbsoluteFilePath_clicked()
{showBtnInfo(sender());QString sourceFile = ui->lineEditFile->text();QFileInfo fileInfo(sourceFile);QString absfilePath = fileInfo.absoluteFilePath();ui->plainTextEdit->appendPlainText(absfilePath);
}
// absolutePath()
void Dialog::on_btnAbsolutePath_clicked()
{showBtnInfo(sender());QString sourceFile = ui->lineEditFile->text();QFileInfo fileInfo(sourceFile);QString absfilePath = fileInfo.absolutePath();ui->plainTextEdit->appendPlainText(absfilePath);
}
// fileInfo.fileName()
void Dialog::on_btnFileName_clicked()
{showBtnInfo(sender());QString sourceFile = ui->lineEditFile->text();QFileInfo fileInfo(sourceFile);QString fileName = fileInfo.fileName();ui->plainTextEdit->appendPlainText(fileName);
}
// fileInfo.filePath()
void Dialog::on_btnFilePath_clicked()
{showBtnInfo(sender());QString sourceFile = ui->lineEditFile->text();QFileInfo fileInfo(sourceFile);QString filePath = fileInfo.filePath();ui->plainTextEdit->appendPlainText(filePath);
}
// fileInfo.size()
void Dialog::on_btnSize_clicked()
{showBtnInfo(sender());QString sourceFile = ui->lineEditFile->text();QFileInfo fileInfo(sourceFile);QString fileSize = QString::number(fileInfo.size());ui->plainTextEdit->appendPlainText(fileSize+"Bytes");
}
// fileInfo.path()
void Dialog::on_btnPath_clicked()
{showBtnInfo(sender());QString sourceFile = ui->lineEditFile->text();QFileInfo fileInfo(sourceFile);QString path = fileInfo.path();ui->plainTextEdit->appendPlainText(path);
}
// fileInfo.baseName()
void Dialog::on_btnBaseName_clicked()
{showBtnInfo(sender());QString sourceFile = ui->lineEditFile->text();QFileInfo fileInfo(sourceFile);QString baseName = fileInfo.baseName();ui->plainTextEdit->appendPlainText(baseName);
}
// fileInfo.completeBaseName()
void Dialog::on_btnCompleteBaseName_clicked()
{showBtnInfo(sender());QString sourceFile = ui->lineEditFile->text();QFileInfo fileInfo(sourceFile);QString completeBaseName = fileInfo.completeBaseName();ui->plainTextEdit->appendPlainText(completeBaseName);
}
// fileInfo.suffix()
void Dialog::on_btnSuffix_clicked()
{showBtnInfo(sender());QString sourceFile = ui->lineEditFile->text();QFileInfo fileInfo(sourceFile);QString suffix = fileInfo.suffix();ui->plainTextEdit->appendPlainText(suffix);
}
// fileInfo.completeSuffix()
void Dialog::on_btnCompleteSuffix_clicked()
{showBtnInfo(sender());QString sourceFile = ui->lineEditFile->text();QFileInfo fileInfo(sourceFile);QString completeSuffix = fileInfo.completeSuffix();ui->plainTextEdit->appendPlainText(completeSuffix);
}
// fileInfo.isDir()
void Dialog::on_btnIsDir_clicked()
{showBtnInfo(sender());QString sourceFile = ui->lineEditFile->text();QFileInfo fileInfo(sourceFile);if(fileInfo.isDir()){ui->plainTextEdit->appendPlainText("目录");} else {ui->plainTextEdit->appendPlainText("非目录");}
}
// fileInfo.isFile()
void Dialog::on_btnIsFile_clicked()
{showBtnInfo(sender());QString sourceFile = ui->lineEditFile->text();QFileInfo fileInfo(sourceFile);if(fileInfo.isFile()){ui->plainTextEdit->appendPlainText("文件");} else {ui->plainTextEdit->appendPlainText("非文件");}
}
// fileInfo.isExecutable()
void Dialog::on_btnIsExecutable_clicked()
{showBtnInfo(sender());QString sourceFile = ui->lineEditFile->text();QFileInfo fileInfo(sourceFile);if(fileInfo.isExecutable()){ui->plainTextEdit->appendPlainText("执行文件");} else {ui->plainTextEdit->appendPlainText("非执行文件");}
}
// fileInfo.birthTime()
void Dialog::on_btnBirthTime_clicked()
{showBtnInfo(sender());QString sourceFile = ui->lineEditFile->text();QFileInfo fileInfo(sourceFile);if(fileInfo.exists()){ui->plainTextEdit->appendPlainText("创建时间:"+fileInfo.birthTime().toString("yyyy-MM-dd hh:mm:ss"));}
}
// fileInfo.lastModified()
void Dialog::on_btnLastModified_clicked()
{showBtnInfo(sender());QString sourceFile = ui->lineEditFile->text();QFileInfo fileInfo(sourceFile);if(fileInfo.exists()){ui->plainTextEdit->appendPlainText("最后修改时间:"+fileInfo.lastModified().toString("yyyy-MM-dd hh:mm:ss"));}
}
// fileInfo.lastRead()
void Dialog::on_btnLastRead_clicked()
{showBtnInfo(sender());QString sourceFile = ui->lineEditFile->text();QFileInfo fileInfo(sourceFile);if(fileInfo.exists()){ui->plainTextEdit->appendPlainText("最后读取时间:"+fileInfo.lastRead().toString("yyyy-MM-dd hh:mm:ss"));}
}
// QFileInfo::exists(sourceFile)
void Dialog::on_btnStaticExists_clicked()
{showBtnInfo(sender());QString sourceFile = ui->lineEditFile->text();if(QFileInfo::exists(sourceFile)){ui->plainTextEdit->appendPlainText("文件存在");} else {ui->plainTextEdit->appendPlainText("文件不存在");}
}
// fileInfo.exists()
void Dialog::on_btnDynamicExists_clicked()
{showBtnInfo(sender());QString sourceFile = ui->lineEditFile->text();QFileInfo fileInfo(sourceFile);if(fileInfo.exists()){ui->plainTextEdit->appendPlainText("文件存在");} else {ui->plainTextEdit->appendPlainText("文件不存在");}
}
// QDir::tempPath()
void Dialog::on_btnTempPath_clicked()
{showBtnInfo(sender());ui->plainTextEdit->appendPlainText("tempPath:"+QDir::tempPath());
}
// QDir::rootPath()
void Dialog::on_btnRootPath_clicked()
{showBtnInfo(sender());ui->plainTextEdit->appendPlainText("rootPath:"+QDir::rootPath());
}
// QDir::homePath()
void Dialog::on_btnHomePath_clicked()
{showBtnInfo(sender());ui->plainTextEdit->appendPlainText("homePath:"+QDir::homePath());
}
// QDir::drives()
void Dialog::on_btnDrives_clicked()
{showBtnInfo(sender());QFileInfoList filelist = QDir::drives();for(auto &fileInfo : filelist){ui->plainTextEdit->appendPlainText(fileInfo.path());}
}
// QDir::currentPath()
void Dialog::on_btnCurrentPath_clicked()
{showBtnInfo(sender());ui->plainTextEdit->appendPlainText("currentPath:"+QDir::currentPath());
}// QDir::setCurrent(ui->lineEditDir->text())
void Dialog::on_btnSetCurrent_clicked()
{showBtnInfo(sender());QDir::setCurrent(ui->lineEditDir->text());ui->plainTextEdit->appendPlainText("currentPath:"+QDir::currentPath());
}
// dir.mkdir(subDir)
void Dialog::on_btnMkdir_clicked()
{showBtnInfo(sender());QString subDir = "subdir";QDir dir(ui->lineEditDir->text());if(dir.mkdir(subDir)){ui->plainTextEdit->appendPlainText("创建成功:"+subDir);} else {ui->plainTextEdit->appendPlainText("创建失败:"+subDir);}
}
// dir.rmdir(subDir)
void Dialog::on_btnRmdir_clicked()
{showBtnInfo(sender());QString subDir = "subdir";QDir dir(ui->lineEditDir->text());if(dir.rmdir(subDir)){ui->plainTextEdit->appendPlainText("删除成功:"+subDir);} else {ui->plainTextEdit->appendPlainText("删除失败:"+subDir);}
}
// dir.remove(fileName)
void Dialog::on_btnRemove_3_clicked()
{showBtnInfo(sender());QString fileName = ui->lineEditFile->text();QDir dir(ui->lineEditDir->text());if(dir.remove(fileName)){ui->plainTextEdit->appendPlainText("删除成功:"+fileName);} else {ui->plainTextEdit->appendPlainText("删除失败:"+fileName);}
}
// dir.rename(fileName, newFile)
void Dialog::on_btnDirRename_clicked()
{showBtnInfo(sender());QString fileName = ui->lineEditFile->text();QFileInfo fileInfo(fileName);QDir dir(ui->lineEditDir->text());QString newFile = fileInfo.path()+"/"+fileInfo.baseName()+".XYZ";if(dir.rename(fileName, newFile)){ui->plainTextEdit->appendPlainText("源文件:"+fileName);ui->plainTextEdit->appendPlainText("修改后的文件:"+newFile);} else {ui->plainTextEdit->appendPlainText("修改失败");}
}
// lastDir.setPath(aDir)
void Dialog::on_btnSetPath_clicked()
{showBtnInfo(sender());QString curDir = QDir::currentPath();QDir lastDir(curDir);ui->plainTextEdit->appendPlainText("当前目录:"+lastDir.absolutePath());QString aDir = QFileDialog::getExistingDirectory(this, "选择一个目录",curDir);if(aDir.isEmpty()){return;}ui->lineEditDir->setText(aDir);lastDir.setPath(aDir);ui->plainTextEdit->appendPlainText("选择后的目录:"+lastDir.absolutePath());
}
// aDir.removeRecursively()
void Dialog::on_btnRemoveRecursively_clicked()
{showBtnInfo(sender());QDir aDir(ui->lineEditDir->text());if(aDir.removeRecursively()){ui->plainTextEdit->appendPlainText("递归删除成功");} else {ui->plainTextEdit->appendPlainText("递归删除失败");}
}
// aDir.absoluteFilePath(ui->lineEditFile->text())
void Dialog::on_btnAbsoluteFilePath_2_clicked()
{showBtnInfo(sender());QDir aDir(ui->lineEditDir->text());QString str = aDir.absoluteFilePath(ui->lineEditFile->text());ui->plainTextEdit->appendPlainText(str);
}
// aDir.absolutePath()
void Dialog::on_btnDirAbsolutePath_clicked()
{showBtnInfo(sender());QDir aDir(ui->lineEditDir->text());ui->plainTextEdit->appendPlainText(aDir.absolutePath());
}
// aDir.canonicalPath()
void Dialog::on_btnCanonicalPath_clicked()
{showBtnInfo(sender());QDir aDir(ui->lineEditDir->text());ui->plainTextEdit->appendPlainText(aDir.canonicalPath());
}
// aDir.filePath(ui->lineEditFile->text())
void Dialog::on_btnDirFilePath_clicked()
{showBtnInfo(sender());QDir aDir(ui->lineEditDir->text());QString filePath = aDir.filePath(ui->lineEditFile->text());ui->plainTextEdit->appendPlainText(filePath);
}
// aDir.path()
void Dialog::on_btnDirPath_clicked()
{showBtnInfo(sender());QDir aDir(ui->lineEditDir->text());ui->plainTextEdit->appendPlainText(aDir.path());
}
// aDir.dirName()
void Dialog::on_btnDirName_clicked()
{showBtnInfo(sender());QDir aDir(ui->lineEditDir->text());ui->plainTextEdit->appendPlainText(aDir.dirName());
}
// aDir.exists()
void Dialog::on_btnDirExists_clicked()
{showBtnInfo(sender());QDir aDir(ui->lineEditDir->text());if(aDir.exists()){ui->plainTextEdit->appendPlainText("存在:"+aDir.dirName());} else {ui->plainTextEdit->appendPlainText("不存在:"+aDir.dirName());}}
// aDir.isEmpty()
void Dialog::on_btnDirIsEmpty_clicked()
{showBtnInfo(sender());QDir aDir(ui->lineEditDir->text());if(aDir.isEmpty()){ui->plainTextEdit->appendPlainText("空文件夹:"+aDir.dirName());} else {ui->plainTextEdit->appendPlainText("非空文件夹:"+aDir.dirName());}
}
// aDir.entryList(QDir::Dirs | QDir::NoDotAndDotDot)
void Dialog::on_btnDirEntryList_clicked()
{showBtnInfo(sender());QDir aDir(ui->lineEditDir->text());QStringList strList = aDir.entryList(QDir::Dirs | QDir::NoDotAndDotDot);ui->plainTextEdit->appendPlainText(aDir.dirName()+"目录下的所有目录:");for(QString &dir : strList){ui->plainTextEdit->appendPlainText(dir);}
}
// aDir.entryList(QDir::Files)
void Dialog::on_btnFileEntryList_clicked()
{showBtnInfo(sender());QDir aDir(ui->lineEditDir->text());QStringList strList = aDir.entryList(QDir::Files);ui->plainTextEdit->appendPlainText(aDir.dirName()+"目录下的所有文件:");for(QString &dir : strList){ui->plainTextEdit->appendPlainText(dir);}
}
// 1.在系统临时目录下创建临时文件夹
void Dialog::on_btnCreateTmpDir_clicked()
{showBtnInfo(sender());ui->plainTextEdit->appendPlainText("QDir::tempPath()="+QDir::tempPath());QTemporaryDir dir;dir.setAutoRemove(true);ui->plainTextEdit->appendPlainText(dir.path());
}
// 1.在系统临时目录下创建临时文件
void Dialog::on_btnCreateTmpFile_clicked()
{showBtnInfo(sender());ui->plainTextEdit->appendPlainText("QDir::tempPath()="+QDir::tempPath());QTemporaryFile aFile;aFile.setAutoRemove(true);aFile.open();ui->plainTextEdit->appendPlainText(aFile.fileName());aFile.close();
}
// 2.在指定目录下创建临时文件夹
void Dialog::on_btnCreateTmpDir_2_clicked()
{showBtnInfo(sender());QString specDir = ui->lineEditDir->text();ui->plainTextEdit->appendPlainText("指定目录="+specDir);QTemporaryDir dir(specDir + "/TempDir_XXX");dir.setAutoRemove(false);ui->plainTextEdit->appendPlainText(dir.path());
}
// 2.在指定目录下创建临时文件
void Dialog::on_btnCreateTmpFile_2_clicked()
{showBtnInfo(sender());QString specDir = ui->lineEditDir->text();ui->plainTextEdit->appendPlainText("指定目录="+specDir);QTemporaryFile aFile(specDir+"/TempFile_XXX");aFile.setAutoRemove(false);aFile.open();ui->plainTextEdit->appendPlainText(aFile.fileName());aFile.close();
}
// 3.在当前目录下创建临时文件夹
void Dialog::on_btnCreateCurTmpDir_clicked()
{showBtnInfo(sender());ui->plainTextEdit->appendPlainText("当前路径="+QDir::currentPath());QTemporaryDir dir("SubDir_XXX");dir.setAutoRemove(false);ui->plainTextEdit->appendPlainText(dir.path());
}
// 3.在当前目录下创建临时文件
void Dialog::on_btnCreateCurTmpFile_clicked()
{showBtnInfo(sender());ui->plainTextEdit->appendPlainText("当前路径="+QDir::currentPath());QTemporaryFile aFile("CurTempFile_XXX.temp");aFile.setAutoRemove(false);aFile.open();ui->plainTextEdit->appendPlainText(aFile.fileName());aFile.close();
}
void Dialog::do_directoryChanged(const QString &path)
{ui->plainTextEdit->appendPlainText(path + "目录发生了变化");
}void Dialog::do_fileChanged(const QString &path)
{ui->plainTextEdit->appendPlainText(path+"文件发生了变化");
}
// addPath()并开始监视
void Dialog::on_btnAddPathWatcher_clicked()
{showBtnInfo(sender());if(fileWatcher == NULL){fileWatcher = new QFileSystemWatcher(this);}fileWatcher->addPath(ui->lineEditDir->text());fileWatcher->addPath(ui->lineEditFile->text());connect(fileWatcher, &QFileSystemWatcher::directoryChanged, this, &Dialog::do_directoryChanged);connect(fileWatcher, &QFileSystemWatcher::fileChanged, this, &Dialog::do_fileChanged);
}
// removePath()并停止监视
void Dialog::on_btnRemovePathWatcher_clicked()
{showBtnInfo(sender());fileWatcher->removePath(ui->lineEditDir->text());fileWatcher->removePath(ui->lineEditFile->text());disconnect(fileWatcher);
}
// directories()
void Dialog::on_btnDirectories_clicked()
{showBtnInfo(sender());for(auto &item : fileWatcher->directories()){ui->plainTextEdit->appendPlainText(item);}
}
// files()
void Dialog::on_btnFiles_clicked()
{showBtnInfo(sender());for(QString &item : fileWatcher->files()){ui->plainTextEdit->appendPlainText(item);}
}

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.hqwc.cn/news/416650.html

如若内容造成侵权/违法违规/事实不符,请联系编程知识网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

TypeScript语法总结

JavaScript 与 TypeScript 的区别 TypeScript 是 JavaScript 的超集&#xff0c;扩展了 JavaScript 的语法&#xff0c;因此现有的 JavaScript 代码可与 TypeScript 一起工作无需任何修改&#xff0c;TypeScript 通过类型注解提供编译时的静态类型检查。 TypeScript 可处理已…

什么是DOM?(JavaScript DOM是什么?)

1、DOM简洁 DOM是js中最重要的一部分&#xff0c;没有DOM就不会通过js实现和用户之间的交互。 window是最大的浏览器对象&#xff0c;在它的下面还有很多子对象&#xff0c;我们要学习的DOM就是window对象下面的document对象 DOM&#xff08;Document Object Model&#xff09…

Unity导出Android项目踩坑记录

1、buildSetting-> 设置ExportProject 2、buildsetting ->playerSetting ->设置IL2CPP 3、设置ndk edit->preferences->external tools->ndk 如果unity的ndk版本和android项目里的ndk版本不一致会报错&#xff0c;让人很崩溃的 4、支持64位配置 buildsetti…

【Java】JDBC的使用

JDBC package jdbc_demo;import java.sql.Connection; import java.sql.DriverManager; import java.sql.Statement;public class jdbc {public static void main(String[] args)throws Exception {//1.注册驱动Class.forName("com.mysql.cj.jdbc.Driver");//2.获取…

c JPEG 1D DCT 优化二(AAN)

这两个图可能就是AAN 的数学模型 优化DCT就是用代码实现矩阵9,10 9和10已经把64个系数缩小到一半32个了。光从这两图可看出&#xff0c;优化后乘法少了64-32436个&#xff0c;加法少了64-32-824。估计优化时间可少百分之40左右。 实际编码640480 的图片&#xff0c;程序执行时…

FlinkSQL【分组聚合-多维分析-性能调优】应用实例分析

FlinkSQL处理如下实时数据需求&#xff1a; 实时聚合不同 类型/账号/发布时间 的各个指标数据&#xff0c;比如&#xff1a;初始化/初始化后删除/初始化后取消/推送/成功/失败 的指标数据。要求实时产出指标数据&#xff0c;数据源是mysql cdc binlog数据。 代码实例 --SET t…

解决系统开发中的跨域问题:CORS、JSONP、Nginx

文章目录 一、概述1.问题场景2.浏览器的同源策略3.解决思路 二、一点准备工作1.创建前端工程12.创建后端工程3.创建前端工程24.跨域问题 三、方法1&#xff1a;使用CORS四、方法2&#xff1a;JSONP五、方法3&#xff1a;Nginx1.安装和启动&#xff08;windows&#xff09;2.使用…

TestNG注释

目录 TestNG注释列表 BeforeXXX和AfterXXX注释放在超类上时如何工作&#xff1f; 使用BeforeXXX和AfterXXX TestNG注释 TestNG是一个测试框架&#xff0c;旨在简化广泛的测试需求&#xff0c;从单元测试&#xff08;隔离测试一个类&#xff09;到集成测试&#xff08;测试由…

【LGR-172-Div.4】洛谷入门赛 #19(A—H,c++详解!)

文章目录 【LGR-172-Div.4】洛谷入门赛 #19A.分饼干 I题目描述输入格式输出格式样例 #1样例输入 #1样例输出 #1 样例 #2样例输入 #2样例输出 #2 提示样例解释 1样例解释 2数据范围与约定思路: 代码 B.分饼干 II题目描述输入格式输出格式样例 #1样例输入 #1样例输出 #1 样例 #2样…

书生·浦语大模型实战营第四次课堂笔记

先来看看参考作业 哈哈到这才想起来写笔记 倒回去看发现要求将不要葱姜蒜换成自己的名字和昵称&#xff01; 好好好我就是不配玩&#xff08;换成管理员也不行&#xff01;&#xff09; 诶怎么能进这个环境&#xff1f;要进双系统ubuntu&#xff1f; 现在看视频发现原来是…

HarmonyOS 页面跳转控制整个界面的转场动画

好 本文 我们来说 页面间的转场动画 就是 第一个界面到另一个界面 第一个界面的退场和第二个界面的进场效果 首先 我这里 创建了两个页面文件 Index.ets和AppView.ets index组件 编写代码如下 import router from "ohos.router" Entry Component struct Index {b…

鉴源实验室|自动驾驶仿真测试技术分析

01 引言 随着科技的不断发展&#xff0c;自动驾驶技术逐渐成为汽车行业的热门话题。然而&#xff0c;要将自动驾驶车辆投放到真实道路上之前&#xff0c;必须进行广泛的测试&#xff0c;以确保其在各种情况下都能安全可靠地运行。自动驾驶车辆的测试是一个复杂而昂贵的过程。…