QXmlSchema
creates, among other things, a message handler that inherits from QObject
. Since this message handler will use the Qt event system, an event loop is required (a structure that processes the queue and event routing). As error messages report, the main event loop is created along with your QApplication
.
If you are creating a GUI application, usually you should have a small amount of code in your main()
function, for example:
int main(int argc, char *argv[]) { QApplication a(argc, argv); MainWindow w; w.show(); return a.exec(); }
Run your code, for example, in the MainWindow
constructor:
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { ui->setupUi(this); QUrl url("http://www.schema-example.org/myschema.xsd"); QXmlSchema schema; if (schema.load(url) == true) qDebug() << "schema is valid"; else qDebug() << "schema is invalid"; }
source share