QGIS API Documentation
2.14.11-Essen
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Properties
Friends
Macros
Modules
Pages
src
gui
editorwidgets
core
qgswidgetwrapper.h
Go to the documentation of this file.
1
/***************************************************************************
2
qgswidgetwrapper.h
3
--------------------------------------
4
Date : 14.5.2014
5
Copyright : (C) 2013 Matthias Kuhn
6
Email : matthias at opengis dot ch
7
***************************************************************************
8
* *
9
* This program is free software; you can redistribute it and/or modify *
10
* it under the terms of the GNU General Public License as published by *
11
* the Free Software Foundation; either version 2 of the License, or *
12
* (at your option) any later version. *
13
* *
14
***************************************************************************/
15
16
#ifndef QGSWIDGETWRAPPER_H
17
#define QGSWIDGETWRAPPER_H
18
19
#include <QObject>
20
#include <QMap>
21
#include <QVariant>
22
23
class
QgsVectorLayer
;
24
25
#include "
qgseditorwidgetconfig.h
"
26
#include "
qgsattributeeditorcontext.h
"
27
39
class
GUI_EXPORT
QgsWidgetWrapper
:
public
QObject
40
{
41
Q_OBJECT
42
public
:
50
explicit
QgsWidgetWrapper
(
QgsVectorLayer
* vl,
QWidget
* editor =
nullptr
,
QWidget
* parent =
nullptr
);
51
57
QWidget
* widget();
58
65
template
<
class
T>
66
T*
widget
() {
return
dynamic_cast<
T
>
( mWidget ); }
67
73
void
setConfig(
const
QgsEditorWidgetConfig
& config );
74
80
void
setContext(
const
QgsAttributeEditorContext
& context );
81
90
QVariant
config(
const
QString
& key,
const
QVariant
& defaultVal =
QVariant
() )
const
;
91
97
QgsEditorWidgetConfig
config()
const
;
98
104
const
QgsAttributeEditorContext
& context()
const
;
105
113
QgsVectorLayer
* layer()
const
;
114
120
static
QgsWidgetWrapper
* fromWidget(
QWidget
* widget );
121
133
virtual
bool
valid()
const
= 0;
134
135
protected
:
147
virtual
QWidget
* createWidget(
QWidget
* parent ) = 0;
148
154
virtual
void
initWidget(
QWidget
* editor );
155
156
public
slots:
163
virtual
void
setFeature(
const
QgsFeature
& feature ) = 0;
164
171
virtual
void
setEnabled(
bool
enabled );
172
173
private
:
174
QgsAttributeEditorContext
mContext;
175
QgsEditorWidgetConfig
mConfig;
176
QWidget
* mWidget;
177
QWidget
* mParent;
178
QgsVectorLayer
* mLayer;
179
bool
mInitialized;
180
};
181
182
// We'll use this class inside a QVariant in the widgets properties
183
Q_DECLARE_METATYPE(
QgsWidgetWrapper
* )
184
185
#endif // QGSWIDGETWRAPPER_H
qgsattributeeditorcontext.h
QWidget
QgsWidgetWrapper::widget
T * widget()
Access the widget managed by this wrapper and cast it to a given type Example: QPushButton* pb = wrap...
Definition:
qgswidgetwrapper.h:66
QgsAttributeEditorContext
This class contains context information for attribute editor widgets.
Definition:
qgsattributeeditorcontext.h:33
QMap
QgsFeature
The feature class encapsulates a single feature including its id, geometry and a list of field/values...
Definition:
qgsfeature.h:187
QObject
QString
qgseditorwidgetconfig.h
QgsVectorLayer
Represents a vector layer which manages a vector based data sets.
Definition:
qgsvectorlayer.h:386
QgsWidgetWrapper
Manages an editor widget Widget and wrapper share the same parent.
Definition:
qgswidgetwrapper.h:39
QVariant
Generated on Wed Jan 25 2017 08:47:22 for QGIS API Documentation by
1.8.8