Custom QT form to edit attributes for shapefiles

Help on using the current version of QGIS

Custom QT form to edit attributes for shapefiles

Postby pauljamesmoran on Tue Jun 15, 2010 12:24 pm

All,
I am having difficulty getting DATES to show well on the custom Qt forms when editing the attributes.
The QT widget DateEdit looks well and stores the selected date into the attribute (of type String). But it does not seem to read the correct value again on startup.
I am using the following

shapefile attribute type = String,
Qt widget = DateEdit
qGIS attribute edit widget= LineEdit

My questions
(1) Has anyone used the QT widget DateEdit or Date/TimeEdit when editing attribute dates ?
(2) In QGIS, I can't seem to create a shapefile attribute of type 'date'. Is 'date' a supported shapefile type?
(3) Is there a way to limit the number of characters in a TextEdit widget. It seems to let me add lots, then truncate it when the layer is saved to the shapefile.

See below how I have configured custom fields for, text, ints, reals, booleans, enums, etc.

Any help would be appreciated.
Thanks
Paul

Here is what is working so far. I am very happy with that way all this works (well done to the developers).
I am listing it here because I have not found this documented anywhere.
Is it documented anywhere?
Is the following correct?

I have created a .ui and registered it in the General tab for my shapefile layer.
The QT widget names are the same as the shapefile attribute names.
The qGIS attribute edit widget (not the QT form designer) is used to setup min/max and allowable values, etc.

SIMPLE TEXT STRING
shapefile attribute type = String,
Qt widget = LineEdit, *** with maxLenght property set as appropriate ***
qGIS attribute edit widget= LineEdit *** no way to set the maxLenght ***

MULTI-LINE TEXT STRING
shapefile attribute type = String,
Qt widget = PlainTextEdit, *** no way to set the maxLenght ***
qGIS attribute edit widget= LineEdit or textEdit (doesn't seem to make any difference) *** no way to set the maxLenght ***

INTEGER
shapefile attribute type = Integer,
Qt widget = SpinBox
qGIS attribute edit widget= Range, with min/max/step configured as appropriate

REAL
shapefile attribute type = real,
Qt widget = DoubleSpinBox
qGIS attribute edit widget= Range, with min/max/step configured as appropriate

EUMERATIONS -COMBOBOX
shapefile attribute type = String,
Qt widget = ComboBox
qGIS attribute edit widget= ValueMap with suitable values(for the shapefile) and descriptions(for the UI).

BOOLEAN - CHECKBOX
shapefile attribute type = String,
Qt widget = Checkbox
qGIS attribute edit widget= Checkbox with 1=checked, 0=unchecked.
pauljamesmoran
 
Posts: 1
Joined: Tue Jun 15, 2010 11:54 am

Re: Custom QT form to edit attributes for shapefiles

Postby underdark on Fri Jun 25, 2010 9:43 pm

Sorry for the late answer.
Is 'date' a supported shapefile type

Couldn't find any information on that in ESRI's whitepaper on the shapefile format. As attributes are stored in the .dbf file and DBF supports datetime values, I'd guess that date is a valid data type for shapefile attributes too. As to which QT widget should be used in custom forms, I'd suggest to contact the developer mailing list. Maybe some kind of spin boxes if the calendar widget doesn't work.
News and tips on QGIS and other geographic information systems: http://underdark.wordpress.org
User avatar
underdark
QGIS Overlord
QGIS Overlord
 
Posts: 936
Joined: Tue Jan 22, 2008 10:39 am

Re: Custom QT form to edit attributes for shapefiles

Postby underdark on Wed Jul 28, 2010 9:40 pm

In Layer Properties - Attributes - Edit Widget, you can chose "Calendar" (at least in QGIS 1.5).
News and tips on QGIS and other geographic information systems: http://underdark.wordpress.org
User avatar
underdark
QGIS Overlord
QGIS Overlord
 
Posts: 936
Joined: Tue Jan 22, 2008 10:39 am


Return to Current Version

Who is online

Users browsing this forum: m_agerlin and 5 guests

cron