QGIS API Documentation 3.38.0-Grenoble (exported)
Loading...
Searching...
No Matches
Public Slots | Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
QgsHistogramWidget Class Reference

Graphical histogram for displaying distributions of field values. More...

#include <qgshistogramwidget.h>

Inheritance diagram for QgsHistogramWidget:
Inheritance graph
[legend]

Public Slots

void refresh ()
 Redraws the histogram.
 
void refreshValues ()
 Refreshes the values for the histogram by fetching them from the layer.
 
void setLayer (QgsVectorLayer *layer)
 Sets the vector layer associated with the histogram.
 
void setSourceFieldExp (const QString &fieldOrExp)
 Sets the source field or expression to use for values in the histogram.
 

Public Member Functions

 QgsHistogramWidget (QWidget *parent=nullptr, QgsVectorLayer *layer=nullptr, const QString &fieldOrExp=QString())
 QgsHistogramWidget constructor.
 
 ~QgsHistogramWidget () override
 
QBrush brush () const
 Returns the brush used when drawing histogram bars.
 
QgsRangeList graduatedRanges () const
 Returns the graduated ranges associated with the histogram.
 
QgsVectorLayerlayer ()
 Returns the layer currently associated with the widget.
 
QPen pen () const
 Returns the pen used when drawing histogram bars.
 
void setBrush (const QBrush &brush)
 Sets the brush used for drawing histogram bars.
 
void setGraduatedRanges (const QgsRangeList &ranges)
 Sets the graduated ranges associated with the histogram.
 
void setPen (const QPen &pen)
 Sets the pen to use when drawing histogram bars.
 
void setXAxisTitle (const QString &title)
 Sets the title for the histogram's x-axis.
 
void setYAxisTitle (const QString &title)
 Sets the title for the histogram's y-axis.
 
QString sourceFieldExp () const
 Returns the source field name or expression used to calculate values displayed in the histogram.
 
QString xAxisTitle () const
 Returns the title for the histogram's x-axis.
 
QString yAxisTitle () const
 Returns the title for the histogram's y-axis.
 

Protected Member Functions

virtual void drawHistogram ()
 Updates and redraws the histogram.
 

Protected Attributes

QwtPlot * mPlot = nullptr
 
QList< QwtPlotMarker * > mRangeMarkers
 
QgsRangeList mRanges
 

Detailed Description

Graphical histogram for displaying distributions of field values.

Definition at line 48 of file qgshistogramwidget.h.

Constructor & Destructor Documentation

◆ QgsHistogramWidget()

QgsHistogramWidget::QgsHistogramWidget ( QWidget *  parent = nullptr,
QgsVectorLayer layer = nullptr,
const QString &  fieldOrExp = QString() 
)

QgsHistogramWidget constructor.

If layer and fieldOrExp are specified then the histogram will be initially populated with the corresponding values.

Parameters
parentparent widget
layersource vector layer
fieldOrExpfield name or expression string

Definition at line 43 of file qgshistogramwidget.cpp.

◆ ~QgsHistogramWidget()

QgsHistogramWidget::~QgsHistogramWidget ( )
override

Definition at line 80 of file qgshistogramwidget.cpp.

Member Function Documentation

◆ brush()

QBrush QgsHistogramWidget::brush ( ) const
inline

Returns the brush used when drawing histogram bars.

See also
setBrush
pen

Definition at line 111 of file qgshistogramwidget.h.

◆ drawHistogram()

void QgsHistogramWidget::drawHistogram ( )
protectedvirtual

Updates and redraws the histogram.

Reimplemented in QgsGraduatedHistogramWidget.

Definition at line 172 of file qgshistogramwidget.cpp.

◆ graduatedRanges()

QgsRangeList QgsHistogramWidget::graduatedRanges ( ) const
inline

Returns the graduated ranges associated with the histogram.

If set, the ranges will be used to color the histogram bars and for showing vertical dividers at the histogram breaks.

Returns
graduated range list
See also
setGraduatedRanges

Definition at line 127 of file qgshistogramwidget.h.

◆ layer()

QgsVectorLayer * QgsHistogramWidget::layer ( )
inline

Returns the layer currently associated with the widget.

See also
setLayer
sourceFieldExp

Definition at line 70 of file qgshistogramwidget.h.

◆ pen()

QPen QgsHistogramWidget::pen ( ) const
inline

Returns the pen used when drawing histogram bars.

See also
setPen
brush

Definition at line 95 of file qgshistogramwidget.h.

◆ refresh

void QgsHistogramWidget::refresh ( )
slot

Redraws the histogram.

Calling this slot does not update the values for the histogram, use refreshValues() to do this.

Definition at line 137 of file qgshistogramwidget.cpp.

◆ refreshValues

void QgsHistogramWidget::refreshValues ( )
slot

Refreshes the values for the histogram by fetching them from the layer.

Definition at line 98 of file qgshistogramwidget.cpp.

◆ setBrush()

void QgsHistogramWidget::setBrush ( const QBrush &  brush)
inline

Sets the brush used for drawing histogram bars.

If ranges have been set using setGraduatedRanges() then the pen and brush will have no effect.

Parameters
brushhistogram brush
See also
brush
setPen

Definition at line 104 of file qgshistogramwidget.h.

◆ setGraduatedRanges()

void QgsHistogramWidget::setGraduatedRanges ( const QgsRangeList ranges)

Sets the graduated ranges associated with the histogram.

If set, the ranges will be used to color the histogram bars and for showing vertical dividers at the histogram breaks.

Parameters
rangesgraduated range list
See also
graduatedRanges

Definition at line 92 of file qgshistogramwidget.cpp.

◆ setLayer

void QgsHistogramWidget::setLayer ( QgsVectorLayer layer)
slot

Sets the vector layer associated with the histogram.

Parameters
layersource vector layer
See also
setSourceFieldExp

Definition at line 142 of file qgshistogramwidget.cpp.

◆ setPen()

void QgsHistogramWidget::setPen ( const QPen &  pen)
inline

Sets the pen to use when drawing histogram bars.

If set to Qt::NoPen then the pen will be automatically calculated. If ranges have been set using setGraduatedRanges() then the pen and brush will have no effect.

Parameters
penhistogram pen
See also
pen
setBrush

Definition at line 88 of file qgshistogramwidget.h.

◆ setSourceFieldExp

void QgsHistogramWidget::setSourceFieldExp ( const QString &  fieldOrExp)
slot

Sets the source field or expression to use for values in the histogram.

Parameters
fieldOrExpfield name or expression string
See also
setLayer

Definition at line 163 of file qgshistogramwidget.cpp.

◆ setXAxisTitle()

void QgsHistogramWidget::setXAxisTitle ( const QString &  title)
inline

Sets the title for the histogram's x-axis.

Parameters
titlex-axis title, or empty string to remove title
See also
xAxisTitle
setYAxisTitle

Definition at line 142 of file qgshistogramwidget.h.

◆ setYAxisTitle()

void QgsHistogramWidget::setYAxisTitle ( const QString &  title)
inline

Sets the title for the histogram's y-axis.

Parameters
titley-axis title, or empty string to remove title
See also
yAxisTitle
setXAxisTitle

Definition at line 157 of file qgshistogramwidget.h.

◆ sourceFieldExp()

QString QgsHistogramWidget::sourceFieldExp ( ) const
inline

Returns the source field name or expression used to calculate values displayed in the histogram.

See also
setSourceFieldExp
layer

Definition at line 78 of file qgshistogramwidget.h.

◆ xAxisTitle()

QString QgsHistogramWidget::xAxisTitle ( ) const
inline

Returns the title for the histogram's x-axis.

See also
setXAxisTitle
yAxisTitle

Definition at line 134 of file qgshistogramwidget.h.

◆ yAxisTitle()

QString QgsHistogramWidget::yAxisTitle ( ) const
inline

Returns the title for the histogram's y-axis.

See also
setYAxisTitle
xAxisTitle

Definition at line 149 of file qgshistogramwidget.h.

Member Data Documentation

◆ mPlot

QwtPlot* QgsHistogramWidget::mPlot = nullptr
protected

Definition at line 193 of file qgshistogramwidget.h.

◆ mRangeMarkers

QList< QwtPlotMarker * > QgsHistogramWidget::mRangeMarkers
protected

Definition at line 195 of file qgshistogramwidget.h.

◆ mRanges

QgsRangeList QgsHistogramWidget::mRanges
protected

Definition at line 194 of file qgshistogramwidget.h.


The documentation for this class was generated from the following files: