本文整理汇总了C++中MessageHandler::statusMessage方法的典型用法代码示例。如果您正苦于以下问题:C++ MessageHandler::statusMessage方法的具体用法?C++ MessageHandler::statusMessage怎么用?C++ MessageHandler::statusMessage使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MessageHandler
的用法示例。
在下文中一共展示了MessageHandler::statusMessage方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: validate
//! [3]
void MainWindow::validate()
{
const QByteArray schemaData = schemaView->toPlainText().toUtf8();
const QByteArray instanceData = instanceEdit->toPlainText().toUtf8();
MessageHandler messageHandler;
QXmlSchema schema;
schema.setMessageHandler(&messageHandler);
schema.load(schemaData);
bool errorOccurred = false;
if (!schema.isValid()) {
errorOccurred = true;
} else {
QXmlSchemaValidator validator(schema);
if (!validator.validate(instanceData))
errorOccurred = true;
}
if (errorOccurred) {
validationStatus->setText(messageHandler.statusMessage());
moveCursor(messageHandler.line(), messageHandler.column());
} else {
validationStatus->setText(tr("validation successful"));
}
const QString styleSheet = QString("QLabel {background: %1; padding: 3px}")
.arg(errorOccurred ? QColor(Qt::red).lighter(160).name() :
QColor(Qt::green).lighter(160).name());
validationStatus->setStyleSheet(styleSheet);
}
示例2: validateXML
ErrorResult validateXML(const QString &fileName, const QString &schemaFileName)
{
QXmlSchema schema;
schema.load(QUrl(schemaFileName));
MessageHandler schemaMessageHandler;
schema.setMessageHandler(&schemaMessageHandler);
if (!schema.isValid())
return ErrorResult(ErrorResultType_Critical, QObject::tr("Schena '%1' is not valid. %2").
arg(schemaFileName).
arg(schemaMessageHandler.statusMessage()));
QFile file(fileName);
file.open(QIODevice::ReadOnly);
QXmlSchemaValidator validator(schema);
MessageHandler validatorMessageHandler;
validator.setMessageHandler(&validatorMessageHandler);
//TODO neslo mi nacist soubor se dvema poli
// if (!validator.validate(&file, QUrl::fromLocalFile(file.fileName())))
// return ErrorResult(ErrorResultType_Critical, QObject::tr("File '%1' is not valid Agros2D problem file. Error (line %3, column %4): %2").
// arg(fileName).
// arg(validatorMessageHandler.statusMessage()).
// arg(validatorMessageHandler.line()).
// arg(validatorMessageHandler.column()));
return ErrorResult();
}
示例3: ouvrir
void Fenetre::ouvrir()
{
QString fileName = QFileDialog::getOpenFileName(this, tr("Séléctionner un fichier"),
QDir::currentPath(),
tr("Fichiers XML (*.xml)"));
if (fileName.isEmpty())
return;
QFile fileXML(fileName);
if (!fileXML.open(QFile::ReadOnly | QFile::Text)) {
QMessageBox::warning(this, tr("Erreur lecture"),
tr("Impossible de lire le fichier %1:\n%2.")
.arg(fileName)
.arg(fileXML.errorString()));
return;
}
QFile fileSchema("schemaGraph.xsd");
fileSchema.open(QIODevice::ReadOnly);
QXmlSchema schema;
MessageHandler messageHandler;
schema.setMessageHandler(&messageHandler);
schema.load(&fileSchema, QUrl::fromLocalFile(fileSchema.fileName()));
if (schema.isValid()) {
QFile fileXML2(fileName);
fileXML2.open(QIODevice::ReadOnly);
QXmlSchemaValidator validator(schema);
if (!validator.validate(&fileXML2, QUrl::fromLocalFile(fileXML2.fileName()))){
QMessageBox::warning(this, tr("Fichier malformé"),
tr("Impossible d'ouvrir le fichier' %1'.\n Le document ne correspond pas au schéma. \n%2")
.arg(fileName)
.arg(messageHandler.statusMessage()));
return;
}
}
ImportExport import=ImportExport(&graphe,xmltree, affichageSVG);
if (import.ouvrir(&fileXML, &domDocument))
ui->statusBar->showMessage(tr("Fichier chargé"), 2000);
affichageSVG->drawGraph();
ui->afficheGraphe->adjustSize();
//On pense à remettre la liste des sommets pour créer les arcs
redessinerComboArc();
}
示例4: validate
bool MainWindow::validate()
{
QUrl url("qrc:/resources/peach.xsd");
const QByteArray instanceData = completingTextEdit->toPlainText().toUtf8();
MessageHandler messageHandler;
QXmlSchema schema;
schema.setMessageHandler(&messageHandler);
schema.load(url);
bool errorOccurred = false;
if (!schema.isValid()) {
errorOccurred = true;
} else {
QXmlSchemaValidator validator(schema);
if (!validator.validate(instanceData))
errorOccurred = true;
}
if (errorOccurred) {
statusLabel->setText(messageHandler.statusMessage());
moveCursor(messageHandler.line(), messageHandler.column());
return false;
} else {
statusLabel->setText(tr("Validation successful"));
return true;
}
const QString styleSheet = QString("QstatusLabel {background: %1; padding: 3px}")
.arg(errorOccurred ? QColor(Qt::red).lighter(160).name() :
QColor(Qt::green).lighter(160).name());
statusLabel->setStyleSheet(styleSheet);
}