Skip to content

Commit eb5cc0c

Browse files
committed
Add method to reset vector layer for data defined button
1 parent b349eb8 commit eb5cc0c

File tree

3 files changed

+19
-1
lines changed

3 files changed

+19
-1
lines changed

python/gui/qgsdatadefinedbutton.sip

+7
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,13 @@ class QgsDataDefinedButton : QToolButton
9494
*/
9595
QgsDataDefined currentDataDefined() const;
9696

97+
/** Sets the vector layer associated with the button. This controls which fields are
98+
* displayed within the widget's pop up menu.
99+
* @param layer vector layer
100+
* @note added in QGIS 3.0
101+
*/
102+
void setVectorLayer( QgsVectorLayer* layer );
103+
97104
/**
98105
* Whether the current data definition or expression is to be used
99106
*/

src/gui/qgsdatadefinedbutton.cpp

+5-1
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,6 @@ void QgsDataDefinedButton::init( const QgsVectorLayer* vl,
195195
mActionDataTypes->setText( tr( "Field type: " ) + mDataTypesString );
196196
}
197197

198-
updateFieldLists();
199198
updateGui();
200199
}
201200

@@ -218,6 +217,11 @@ QgsDataDefined QgsDataDefinedButton::currentDataDefined() const
218217
return dd;
219218
}
220219

220+
void QgsDataDefinedButton::setVectorLayer( QgsVectorLayer* layer )
221+
{
222+
mVectorLayer = layer;
223+
}
224+
221225
void QgsDataDefinedButton::mouseReleaseEvent( QMouseEvent *event )
222226
{
223227
// Ctrl-click to toggle activated state

src/gui/qgsdatadefinedbutton.h

+7
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,13 @@ class GUI_EXPORT QgsDataDefinedButton: public QToolButton
127127
*/
128128
QgsDataDefined currentDataDefined() const;
129129

130+
/** Sets the vector layer associated with the button. This controls which fields are
131+
* displayed within the widget's pop up menu.
132+
* @param layer vector layer
133+
* @note added in QGIS 3.0
134+
*/
135+
void setVectorLayer( QgsVectorLayer* layer );
136+
130137
/**
131138
* Whether the current data definition or expression is to be used
132139
*/

0 commit comments

Comments
 (0)