32 const QFileInfo fi( file );
33 if ( fi.suffix().compare( QLatin1String(
"qpt" ), Qt::CaseInsensitive ) != 0 )
36 QFile templateFile( file );
37 if ( !templateFile.open( QIODevice::ReadOnly ) )
39 QMessageBox::warning( iface->
view(), tr(
"Load from Template" ), tr(
"Could not read template file." ) );
43 QDomDocument templateDoc;
46 if ( templateDoc.setContent( &templateFile ) )
49 const QList<QgsLayoutItem *> items = iface->
layout()->
loadFromTemplate( templateDoc, context,
false, &ok );
52 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.