创建文件夹
如下代码是在单击按钮后,先判断文件夹是否存在,若不存在便创建一个名字为temp的文件夹。
void MainWindow::on_pushButton_2_clicked()
{
QDir *temp = new QDir;
bool exist = temp->exists("D://temp");
if(exist)
QMessageBox::warning(this,tr("创建文件夹"),tr("文件夹已经存在!"));
else
{
bool ok = temp->mkdir("D://temp");
if( ok )
QMessageBox::warning(this,tr("创建文件夹"),tr("文件夹创建成功!"));
}
}
创建文件夹