33 const QFileInfo fi( file );
34 if ( fi.suffix().compare( QLatin1String(
"qpt" ), Qt::CaseInsensitive ) != 0 )
37 QFile templateFile( file );
38 if ( !templateFile.open( QIODevice::ReadOnly ) )
40 QMessageBox::warning( iface->
view(), tr(
"Load from Template" ), tr(
"Could not read template file." ) );
44 QDomDocument templateDoc;
47 if ( templateDoc.setContent( &templateFile ) )
50 const QList< QgsLayoutItem * > items = iface->
layout()->
loadFromTemplate( templateDoc, context,
false, &ok );
53 QMessageBox::warning( iface->
view(), tr(
"Load from Template" ), tr(
"Could not read template file." ) );
QList< QgsLayoutItem * > loadFromTemplate(const QDomDocument &document, const QgsReadWriteContext &context, bool clearExisting=true, bool *ok=nullptr)
Load a layout template document.
The class is used as a container of context for various read/write operations on other objects.
void setPathResolver(const QgsPathResolver &resolver)
Sets up path resolver for conversion between relative and absolute paths.