I've already asked a question about how to access attribute data types when developing a plugin for QGIS, using PyQGIS. And one helpful member said I should use the pendingFields() method on the current layer. Here is the link to that query: Accessing attribute data type in PyQGIS
Indeed I could access them but when I tried to change the data type with setType() and setTypeName() functions, it didn't work. When I queried the objects with type() and typeName() they showed the new data types I have given them, but when I wanted to enter new values for some feature I realized that this layer doesn't recognize new data types.
For example, the first attribute field has by default Real data type, so it recognizes only numbers. I converted that field to String using the command:
fields[0].setType(10)
btw:
fields = currentLayer.pendingFields()
But the field still acts like before and doesn't recognize letters, only numbers. How to change data types? Is it even possible? Or you can only define the data type for a new attribute?