29  mGridPen = QPen( QColor( 190, 190, 190, 100 ), 0 );
 
   30  mGridPen.setCosmetic( 
true );
 
 
   41  mLayout->
undoStack()->
beginCommand( 
this, QObject::tr( 
"Change Grid Resolution" ), UndoGridResolution );
 
 
   58  QString gridStyleString;
 
   59  gridStyleString = s.
value( QStringLiteral( 
"LayoutDesigner/gridStyle" ), 
"Dots", 
QgsSettings::Gui ).toString();
 
   61  int gridRed, gridGreen, gridBlue, gridAlpha;
 
   66  const QColor gridColor = QColor( gridRed, gridGreen, gridBlue, gridAlpha );
 
   68  mGridPen.setColor( gridColor );
 
   69  mGridPen.setWidthF( 0 );
 
   70  mGridPen.setCosmetic( 
true );
 
   72  if ( gridStyleString == QLatin1String( 
"Dots" ) )
 
   76  else if ( gridStyleString == QLatin1String( 
"Crosses" ) )
 
 
   93  QDomElement element = document.createElement( QStringLiteral( 
"Grid" ) );
 
   95  element.setAttribute( QStringLiteral( 
"resolution" ), mGridResolution.
length() );
 
   98  element.setAttribute( QStringLiteral( 
"offsetX" ), mGridOffset.
x() );
 
   99  element.setAttribute( QStringLiteral( 
"offsetY" ), mGridOffset.
y() );
 
  102  parentElement.appendChild( element );
 
 
  108  QDomElement element = e;
 
  109  if ( element.nodeName() != QLatin1String( 
"Grid" ) )
 
  111    element = element.firstChildElement( QStringLiteral( 
"Grid" ) );
 
  114  if ( element.nodeName() != QLatin1String( 
"Grid" ) )
 
  119  const double res = element.attribute( QStringLiteral( 
"resolution" ), QStringLiteral( 
"10" ) ).toDouble();
 
  123  const double offsetX = element.attribute( QStringLiteral( 
"offsetX" ) ).toDouble();
 
  124  const double offsetY = element.attribute( QStringLiteral( 
"offsetY" ) ).toDouble();
 
 
LayoutUnit
Layout measurement units.
 
@ Millimeters
Millimeters.
 
QgsLayoutMeasurement resolution() const
Returns the page/snap grid resolution.
 
QgsLayout * layout() override
Returns the layout the object belongs to.
 
QgsLayoutGridSettings(QgsLayout *layout)
Constructor for QgsLayoutGridSettings.
 
QgsLayoutPoint offset() const
Returns the offset of the page/snap grid.
 
void setOffset(const QgsLayoutPoint &offset)
Sets the offset of the page/snap grid.
 
bool writeXml(QDomElement &parentElement, QDomDocument &document, const QgsReadWriteContext &context) const override
Stores the grid's state in a DOM element.
 
bool readXml(const QDomElement &gridElement, const QDomDocument &document, const QgsReadWriteContext &context) override
Sets the grid's state from a DOM element.
 
void loadFromSettings()
Loads grid settings from the application layout settings.
 
void setResolution(QgsLayoutMeasurement resolution)
Sets the page/snap grid resolution.
 
Provides a method of storing measurements for use in QGIS layouts using a variety of different measur...
 
Qgis::LayoutUnit units() const
Returns the units for the measurement.
 
double length() const
Returns the length of the measurement.
 
void redraw()
Triggers a redraw for all pages.
 
Provides a method of storing points, consisting of an x and y coordinate, for use in QGIS layouts.
 
double x() const
Returns x coordinate of point.
 
double y() const
Returns y coordinate of point.
 
Qgis::LayoutUnit units() const
Returns the units for the point.
 
void endCommand()
Saves final state of an object and pushes the active command to the undo history.
 
void beginCommand(QgsLayoutUndoObjectInterface *object, const QString &commandText, int id=0)
Begins a new undo command for the specified object.
 
Base class for layouts, which can contain items such as maps, labels, scalebars, etc.
 
QgsLayoutPageCollection * pageCollection()
Returns a pointer to the layout's page collection, which stores and manages page items in the layout.
 
QgsLayoutUndoStack * undoStack()
Returns a pointer to the layout's undo stack, which manages undo/redo states for the layout and it's ...
 
A container for the context for various read/write operations on objects.
 
Stores settings for use within QGIS.
 
QVariant value(const QString &key, const QVariant &defaultValue=QVariant(), Section section=NoSection) const
Returns the value for setting key.
 
static Q_INVOKABLE Qgis::LayoutUnit decodeLayoutUnit(const QString &string, bool *ok=nullptr)
Decodes a layout unit from a string.
 
static Q_INVOKABLE QString encodeUnit(Qgis::DistanceUnit unit)
Encodes a distance unit to a string.