title: Qt Designer Custom Widget: using flags
body: <p>I have a problem with the declaration of flags in a widget which is used as a custom widget for QtDesigner.</p>
  
  <p>This widget is a QComboBox using a filter proxy model, called QgsMapLayerComboBox</p>
  
  <p>In the filter proxy model (QgsMapLayerProxyModel), I have defined flags:</p>
  
  <pre><code>class GUI_EXPORT QgsMapLayerProxyModel : public QSortFilterProxyModel
  {
      Q_OBJECT
      Q_FLAGS( Filters )
    public:
      enum Filter
      {
        NoFilter = 1,
        RasterLayer = 2,
        NoGeometry = 4,
        PointLayer = 8,
        LineLayer = 16,
        PolygonLayer = 32,
        HasGeometry = PointLayer | LineLayer | PolygonLayer,
        VectorLayer = NoGeometry | HasGeometry
      };
      Q_DECLARE_FLAGS( Filters, Filter )
  
      ...
  };
  
  Q_DECLARE_OPERATORS_FOR_FLAGS( QgsMapLayerProxyModel::Filters )
  </code></pre>
  
  <p>Now I want to be able to define these settings directly in Qt Designer.
  Hence, I have reused the flags from the proxy model class in the combo box class:</p>
  
  <pre><code>class GUI_EXPORT QgsMapLayerComboBox : public QComboBox
  {
      Q_OBJECT
  
      Q_FLAGS( QgsMapLayerProxyModel::Filters )
      Q_PROPERTY( QgsMapLayerProxyModel::Filters filters READ filters WRITE setFilters )
  
    public:
      explicit QgsMapLayerComboBox( QWidget *parent = 0 );
  
      //! setFilters allows fitering according to layer type and/or geometry type.
      void setFilters( QgsMapLayerProxyModel::Filters filters );
  
      //! currently used filter on list layers
      QgsMapLayerProxyModel::Filters filters(){ return mProxyModel-&gt;filters(); }
  }
  </code></pre>
  
  <p>This is working as expected.</p>
  
  <p>But, these widgets are also compiled in a python library using SIP.
  I have created a module for pyuic (in /usr/lib/python2.7/dist-packages/PyQt4/uic/widget-plugins) so it knows where to look for the widget:</p>
  
  <pre><code>pluginType = MODULE
  def moduleInformation():
      return "qgis.gui", ("QgsMapLayerCombobox", )
  </code></pre>
  
  <p>Now, the problem is that pyuic complains: <code>AttributeError: unknown enum QgsMapLayerProxyModel::RasterLayer</code> because it can't find QgsMapLayerProxyModel.</p>
  
  <p>The only solution that came to my mind was to duplicate the flags in QgsMapLayerComboBox:</p>
  
  <pre><code>class GUI_EXPORT QgsMapLayerComboBox : public QComboBox
  {
      Q_OBJECT
  
      Q_FLAGS( Filters2 )
      Q_PROPERTY( Filters2 filters2 READ filters2 WRITE setFilters2 )
  
    public:
      typedef QgsMapLayerProxyModel::Filter Filter2;
      typedef QgsMapLayerProxyModel::Filters Filters2;
  
      explicit QgsMapLayerComboBox( QWidget *parent = 0 );
  
      //! setFilters allows fitering according to layer type and/or geometry type.
      void setFilters2( Filters2 filters );
  
      //! currently used filter on list layers
      Filters2 filters2(){ return static_cast&lt;Filters2&gt;( mProxyModel-&gt;filters() ); }
  }
  </code></pre>
  
  <p>But this is not working: <strong>I don't see the settings in Qt Designer: do you know why?</strong></p>
  
  <p><strong>Would you think of a better way to solve this?</strong></p>
  
  <p>PS: this is made within QGIS code.</p>