0

Because QGIS opens MS Excell tables with string type only, in processing plugin I need to use any field types.

def deg2dms(degree):
    deg = degree
    d = int(deg)
    m = int((deg - d) * 60)
    s = float(((deg - d) * 60 - m) * 60)
    return "{}°{}'{}''".format(d, m, round(s, 2))

But code executes with error:

d = int(deg) TypeError: int() argument must be a string, a bytes-like object or a number, not 'QVariant'

How to convert type QVariant to float?

1 Answer 1

1

You can use the QVariant.value() method. Applied to your script, it would be something like deg.value().

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.