[Qgis-developer] Trouble in construct attribute dialog

Jacory jacorygao at outlook.com
Wed Jan 6 17:24:21 PST 2016


Hello all

I’ve solved the problems by my self. After calling the QgsEditorWidgetRegistry::initEditor() method, I got the right attribute table. Sorry for bothering you. 
My original email is list below.


Hello all.

This is my third time to send this email to you, I can’t solve the problem, I really want someone can help me, thanks.

I’m now working on a personal GIS project, I want to use some features of QGis. Now I meet a wired thing that I can’t initialize the attribute dialog of a vector layer well, I’m writing to you to see if someone can help me. Thanks.

The code is simple, I paste them here

void qgis_dev::openAttributeTableDialog()
{
    QgsVectorLayer* mylayer = qobject_cast<QgsVectorLayer*>( activeLayer() );
    if ( !mylayer ) { return; }
  
    QgsVectorLayerCache* lc = new QgsVectorLayerCache( mylayer, mylayer->featureCount() );
    QgsAttributeTableView* tv = new QgsAttributeTableView();
    QgsAttributeTableModel* tm = new QgsAttributeTableModel( lc, this );

    QgsAttributeTableFilterModel* tfm = new QgsAttributeTableFilterModel( new QgsMapCanvas(), tm, tm );

    tfm->setFilterMode( QgsAttributeTableFilterModel::ShowAll );
    tm->loadLayer();
    tv->setModel( tfm );
    tv->show();
}

and the result is like this, there are no attributes in the form, but the feature count is right.



However, when I paste these code into QGis source code and compile the project, I get the right result. I don’t know where I am wrong.


Really hope to get some help.

Thank you!


jacorygao at outlook.com <mailto:jacorygao at outlook.com>
=========================




_______________________________________________
Qgis-developer mailing list
Qgis-developer at lists.osgeo.org <mailto:Qgis-developer at lists.osgeo.org>
List info: http://lists.osgeo.org/mailman/listinfo/qgis-developer <http://lists.osgeo.org/mailman/listinfo/qgis-developer>
Unsubscribe: http://lists.osgeo.org/mailman/listinfo/qgis-developer_______________________________________________ <http://lists.osgeo.org/mailman/listinfo/qgis-developer_______________________________________________>
Qgis-developer mailing list
Qgis-developer at lists.osgeo.org <mailto:Qgis-developer at lists.osgeo.org>
List info: http://lists.osgeo.org/mailman/listinfo/qgis-developer
Unsubscribe: http://lists.osgeo.org/mailman/listinfo/qgis-developer_______________________________________________
Qgis-developer mailing list
Qgis-developer at lists.osgeo.org
List info: http://lists.osgeo.org/mailman/listinfo/qgis-developer
Unsubscribe: http://lists.osgeo.org/mailman/listinfo/qgis-developer
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-developer/attachments/20160107/d560b4fd/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: gb2312''QQ%BD%D8%CD%BC20160102171248.png
Type: image/png
Size: 9223 bytes
Desc: not available
URL: <http://lists.osgeo.org/pipermail/qgis-developer/attachments/20160107/d560b4fd/attachment.png>


More information about the Qgis-developer mailing list