woboq/qmetaobject-rs

[Feature Request] Wrapper for QMap<K, T>

Ayush1325 opened this issue · 2 comments

Introduction

I am currently working on a wrapper for the KConfig KDE framework and need to return QMap<K, T> from a function. It seems there are no implementations of QT generic types in qmetaobject yet. I will try to tackle this myself at some point but it seems like it will take a lot more time than I currently have. So just opening this issue if anyone else wants to give it a try.

Helpful Links

  • CxxVector<T>: Binding to C++ std::vector<T, std::allocator>.

We can't have template code like that. So you would need to wrap some specific one, (for example QVariantMap or QMapFooBar as "QMap<Foo, Bar>" for a specific Foo and Bar)
If QMap would have type erasure, we could do it like CxxVector, but it doesn't so we can't have it.

Anyway, i believe, for your usecase the best is not to make a 1-1 API with the C++ API, but return something that make sense for rust.

So i guess QVariantMap would kind of work, would it not?

@ogoffart QVariantMap might work. But I will need the ability to convert to and from Hashmap in Rust.
I did not know it was not possible to have something like generics in Qt types. I guess I will have to study more about type erasures,