本文整理汇总了C++中QErrorMessage::setFont方法的典型用法代码示例。如果您正苦于以下问题:C++ QErrorMessage::setFont方法的具体用法?C++ QErrorMessage::setFont怎么用?C++ QErrorMessage::setFont使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QErrorMessage
的用法示例。
在下文中一共展示了QErrorMessage::setFont方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: process
void XSLExpress::process()
{
QString xslFile = ui->xslFile->text();
QString replaceThis = ui->replaceThis->text();
QString replaceWith = ui->replaceWith->text();
QStringList inputFiles = ui->inputFiles->toPlainText().split("\n", QString::SkipEmptyParts );
if( xslFile.isEmpty() )
return;
if( inputFiles.isEmpty() )
return;
QString failures;
// so for whatever reason this isn't working
QProgressDialog progress( tr("Processing files..."), tr("Cancel"), 0, inputFiles.count(), 0);
progress.setWindowModality(Qt::WindowModal);
Xsltproc transform;
QString lastXmlErrorMessage;
int xmlErrors = 0;
QErrorMessage *errDialog = new QErrorMessage(this);
QFont font("Courier");
font.setStyleHint(QFont::TypeWriter);
errDialog->setFont(font);
errDialog->resize(600,300);
for( int i=0; i<inputFiles.count(); i++)
{
progress.setValue(i);
if (progress.wasCanceled())
break;
QString outputFile = inputFiles.at(i);
outputFile.replace(QRegExp(replaceThis), replaceWith);
if( inputFiles.at(i) == outputFile && !ui->allowOverwrite->isChecked() )
{
failures += inputFiles.at(i) + tr(" (overwrite prevented)\n");
continue;
}
QFileInfo info(inputFiles.at(i));
QString errorFilename = QDir::temp().filePath( tr(".~err-%1!").arg( info.fileName() ) );
QFileInfo errorFileInfo(errorFilename);
QHash<QString,QString> parameters;
for(int j=0; j<aParameterValues.count(); j++)
if( !aParameterNames.at(j)->text().isEmpty() )
parameters.insert( aParameterNames.at(j)->text() , aParameterValues.at(j)->text() );
transform.setStyleSheet(xslFile);
transform.setXmlFilename( inputFiles.at(i) );
transform.setOutputFilename(outputFile);
transform.setErrorFilename(errorFilename);
transform.setParameters(parameters);
Xsltproc::ReturnValue retval = transform.execute();
QString errorMessage;
QFile data(errorFileInfo.absoluteFilePath());
if (data.open(QFile::ReadOnly)) {
QTextStream in(&data);
errorMessage = in.readAll();
errorMessage.replace("\n","<p>").replace(" "," ");
}
switch(retval)
{
case Xsltproc::InvalidStylesheet:
progress.cancel();
errDialog->setWindowTitle(tr("XSL Stylesheet Error"));
errDialog->showMessage(errorMessage);
return;
case Xsltproc::InvalidXmlFile:
lastXmlErrorMessage = errorMessage;
xmlErrors++;
failures += inputFiles.at(i) + tr(" (invalid input file)\n");
break;
case Xsltproc::CouldNotOpenOutput:
failures += inputFiles.at(i) + tr(" (could not open output file)\n");
break;
case Xsltproc::GenericFailure:
failures += inputFiles.at(i) + tr(" (unknown error)\n");
break;
case Xsltproc::Success:
break;
}
QFile::remove(errorFilename);
}
progress.setValue(inputFiles.count());
if(xmlErrors > 1)
{
QMessageBox::information(this,tr("Error Report"),tr("These files quit with an error:\n%1").arg(failures.trimmed()));
errDialog->setWindowTitle(tr("Most recent XML Input Error"));
errDialog->showMessage(lastXmlErrorMessage);
}
else if(xmlErrors > 0)
//.........这里部分代码省略.........