本文整理汇总了C++中QTemporaryFile::fileTemplate方法的典型用法代码示例。如果您正苦于以下问题:C++ QTemporaryFile::fileTemplate方法的具体用法?C++ QTemporaryFile::fileTemplate怎么用?C++ QTemporaryFile::fileTemplate使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QTemporaryFile
的用法示例。
在下文中一共展示了QTemporaryFile::fileTemplate方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main()
{
QTemporaryFile file;
file.setFileTemplate(file.fileTemplate() + ".jpg");
const int N = 100;
for(int j = 0 ; j < N ; j++)
{
file.open();
QImage img(800, 600, QImage::Format_RGB32);
img.save(&file);
file.close();
QString address = file.fileName();
cv::Mat image = cv::imread(address.toStdString(),0);
PD_Classifier_VEC.push_back(image);
}
while (!PD_Classifier_VEC.empty()) PD();
cv::waitKey();
return 0;
}
示例2: LoadFirmwarePackage
void MainWindow::LoadFirmwarePackage(void)
{
workingPackageData.Clear();
currentPitData.Clear();
// Make flashSettings responsible for the temporary files
workingPackageData.GetFiles().append(loadedPackageData.GetFiles());
loadedPackageData.RemoveAllFiles();
const QList<FileInfo> packageFileInfos = loadedPackageData.GetFirmwareInfo().GetFileInfos();
for (int i = 0; i < packageFileInfos.length(); i++)
{
bool fileFound = false;
for (int j = 0; j < workingPackageData.GetFiles().length(); j++)
{
if (workingPackageData.GetFiles()[j]->fileTemplate() == ("XXXXXX-" + packageFileInfos[i].GetFilename()))
{
FileInfo partitionInfo(packageFileInfos[i].GetPartitionId(), QDir::current().absoluteFilePath(workingPackageData.GetFiles()[j]->fileName()));
workingPackageData.GetFirmwareInfo().GetFileInfos().append(partitionInfo);
fileFound = true;
break;
}
}
if (!fileFound)
Alerts::DisplayWarning(QString("%1 is missing from the package.").arg(packageFileInfos[i].GetFilename()));
}
// Find the PIT file and read it
for (int i = 0; i < workingPackageData.GetFiles().length(); i++)
{
QTemporaryFile *file = workingPackageData.GetFiles()[i];
if (file->fileTemplate() == ("XXXXXX-" + loadedPackageData.GetFirmwareInfo().GetPitFilename()))
{
workingPackageData.GetFirmwareInfo().SetPitFilename(QDir::current().absoluteFilePath(file->fileName()));
if (!ReadPit(file))
{
Alerts::DisplayError("Failed to read PIT file.");
loadedPackageData.Clear();
UpdatePackageUserInterface();
workingPackageData.Clear();
UpdateUnusedPartitionIds();
return;
}
break;
}
}
UpdateUnusedPartitionIds();
workingPackageData.GetFirmwareInfo().SetRepartition(loadedPackageData.GetFirmwareInfo().GetRepartition());
workingPackageData.GetFirmwareInfo().SetNoReboot(loadedPackageData.GetFirmwareInfo().GetNoReboot());
loadedPackageData.Clear();
UpdatePackageUserInterface();
firmwarePackageLineEdit->clear();
partitionsListWidget->clear();
// Populate partitionsListWidget with partition names (from the PIT file)
for (int i = 0; i < workingPackageData.GetFirmwareInfo().GetFileInfos().length(); i++)
{
const FileInfo& partitionInfo = workingPackageData.GetFirmwareInfo().GetFileInfos()[i];
const PitEntry *pitEntry = currentPitData.FindEntry(partitionInfo.GetPartitionId());
if (pitEntry)
{
partitionsListWidget->addItem(pitEntry->GetPartitionName());
}
else
{
Alerts::DisplayError("Firmware package includes invalid partition IDs.");
loadedPackageData.GetFirmwareInfo().Clear();
currentPitData.Clear();
UpdateUnusedPartitionIds();
partitionsListWidget->clear();
return;
}
}
partitionNameComboBox->clear();
partitionIdLineEdit->clear();
partitionFileLineEdit->clear();
partitionFileBrowseButton->setEnabled(false);
repartitionCheckBox->setEnabled(true);
repartitionCheckBox->setChecked(workingPackageData.GetFirmwareInfo().GetRepartition());
noRebootCheckBox->setEnabled(true);
noRebootCheckBox->setChecked(workingPackageData.GetFirmwareInfo().GetNoReboot());
//.........这里部分代码省略.........
示例3: ExtractPackage
bool Packaging::ExtractPackage(const QString& packagePath, PackageData *packageData)
{
FILE *compressedPackageFile = fopen(packagePath.toStdString().c_str(), "rb");
if (!compressedPackageFile)
{
Alerts::DisplayError(QString("Failed to open package:\n%1").arg(packagePath));
return (false);
}
fseek(compressedPackageFile, 0, SEEK_END);
quint64 compressedFileSize = ftell(compressedPackageFile);
rewind(compressedPackageFile);
gzFile packageFile = gzdopen(fileno(compressedPackageFile), "rb");
QTemporaryFile outputTar("XXXXXX.tar");
if (!outputTar.open())
{
Alerts::DisplayError("Failed to open temporary TAR archive.");
gzclose(packageFile);
return (false);
}
char buffer[kExtractBufferLength];
int bytesRead;
quint64 totalBytesRead = 0;
QProgressDialog progressDialog("Decompressing package...", "Cancel", 0, compressedFileSize);
progressDialog.setWindowModality(Qt::ApplicationModal);
progressDialog.setWindowTitle("Heimdall Frontend");
do
{
bytesRead = gzread(packageFile, buffer, kExtractBufferLength);
if (bytesRead == -1)
{
progressDialog.close();
Alerts::DisplayError("Error decompressing archive.");
gzclose(packageFile);
return (false);
}
outputTar.write(buffer, bytesRead);
totalBytesRead += bytesRead;
progressDialog.setValue(totalBytesRead);
if (progressDialog.wasCanceled())
{
gzclose(packageFile);
progressDialog.close();
return (false);
}
} while (bytesRead > 0);
progressDialog.close();
outputTar.close();
gzclose(packageFile); // Closes packageFile and compressedPackageFile
if (!ExtractTar(outputTar, packageData))
return (false);
// Find and read firmware.xml
for (int i = 0; i < packageData->GetFiles().length(); i++)
{
QTemporaryFile *file = packageData->GetFiles()[i];
if (file->fileTemplate() == "XXXXXX-firmware.xml")
{
if (!packageData->ReadFirmwareInfo(file))
{
packageData->Clear();
return (false);
}
return (true);
}
}
Alerts::DisplayError("firmware.xml is missing from the package.");
return (false);
}