[Qgis-developer] Trouble in construct attribute dialog

Jacory jacorygao at outlook.com
Tue Jan 5 22:33:58 PST 2016

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 );
    tv->setModel( tfm );

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
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/20160106/a547a932/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: QQ??20160102171248.png
Type: image/png
Size: 9223 bytes
Desc: not available
URL: <http://lists.osgeo.org/pipermail/qgis-developer/attachments/20160106/a547a932/attachment.png>

More information about the Qgis-developer mailing list