QXmlSchema
creates, among other things, a message handler which inherits from QObject
. Since this message handler will be using Qt's event system, an event loop (the structure which handles queueing and routing of events) is required. As the error messages tell you, the main event loop is created along with your QApplication
.
If you're creating a GUI application generally you should have a small amount of code in your main()
function, something like:
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
MainWindow w;
w.show();
return a.exec();
}
Start your code off in, say, the constructor of MainWindow
:
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";
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…