Hi,
Not sure if this is a newbie question or not, but I can't get the example code from
http://qt.developpez.com/doc/4.7/qxmlschema/
to work. My minimum test case is
//
#include <QXmlSchema>
QUrl schemaUrl
("file:///home/mark/adversity/stylesheets/ttl_stylesheets.xsd");
QXmlSchema schema;
schema.load(schemaUrl);
#include <QXmlSchema>
QUrl schemaUrl("file:///home/mark/adversity/stylesheets/ttl_stylesheets.xsd");
QXmlSchema schema;
schema.load(schemaUrl);
To copy to clipboard, switch view to plain text mode
//
My .pro file is
//
TEMPLATE = app
TARGET =
DEPENDPATH += .
INCLUDEPATH += .
QT += xmlpatterns
# Input
SOURCES += main.cpp
TEMPLATE = app
TARGET =
DEPENDPATH += .
INCLUDEPATH += .
QT += xmlpatterns
# Input
SOURCES += main.cpp
To copy to clipboard, switch view to plain text mode
//
When I try to compile this with Ubuntu 11.04 (which appears to be QT 4.7.2) I get
##
$ make
g++ -c -pipe -O2 -Wall -W -D_REENTRANT -DQT_NO_DEBUG -DQT_XMLPATTERNS_LIB -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED -I/usr/share/qt4/mkspecs/linux-g++ -I. -I/usr/include/qt4/QtCore -I/usr/include/qt4/QtGui -I/usr/include/qt4/QtXmlPatterns -I/usr/include/qt4 -I. -I. -o main.o main.cpp
main.cpp:6:1: error: ‘schema’ does not name a type
make: *** [main.o] Erreur 1
$ make
g++ -c -pipe -O2 -Wall -W -D_REENTRANT -DQT_NO_DEBUG -DQT_XMLPATTERNS_LIB -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED -I/usr/share/qt4/mkspecs/linux-g++ -I. -I/usr/include/qt4/QtCore -I/usr/include/qt4/QtGui -I/usr/include/qt4/QtXmlPatterns -I/usr/include/qt4 -I. -I. -o main.o main.cpp
main.cpp:6:1: error: ‘schema’ does not name a type
make: *** [main.o] Erreur 1
To copy to clipboard, switch view to plain text mode
##
The thing I really don't understand is why, if there's a compiling problem, it isn't flagged on line 5, ie
QXmlSchema schema;
QXmlSchema schema;
To copy to clipboard, switch view to plain text mode
If that line compiles correctly, I can't see why 'schema' in
schema.load(schemaUrl);
schema.load(schemaUrl);
To copy to clipboard, switch view to plain text mode
does not name a type.
I've compiled several other fairly substantial QT programs in this environment, including one using SAX, so the problem appears to be quite specific.
All suggestions gratefully received...
(Obviously my code is missing a main(), but the compiler isn't getting far enough for that to be an issue...)
Added after 13 minutes:
(Although, obviously, not wrapping the code within a function definition changes the context, and if I do that it does compile. Oh well...)
Bookmarks