Hello every one.
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; }
//qgis_devattrtableDialog* d = new qgis_devattrtableDialog( mylayer, this );
// d->show();
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!
[email protected]
=========================
_______________________________________________
Qgis-developer mailing list
[email protected]
List info: http://lists.osgeo.org/mailman/listinfo/qgis-developer
Unsubscribe: http://lists.osgeo.org/mailman/listinfo/qgis-developer