Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

QStringList not mapped #39

Open
byteit101 opened this issue Oct 26, 2020 · 1 comment
Open

QStringList not mapped #39

byteit101 opened this issue Oct 26, 2020 · 1 comment

Comments

@byteit101
Copy link
Contributor

This is making it much more difficult to do stuff, such as: Qt::Completer.new(["Option 1", "Option 2"], parent) must be replaced with a full blown model.

@HertzDevil
Copy link
Contributor

QStringList is technically unsupported, because it inherits from QList<QString> which in turn inherits from QListSpecialMethods<QString>, where several methods are ultimately defined:

template <typename T> struct QListSpecialMethods { };
template <> struct QListSpecialMethods<QString>;

template <typename T>
class QList : public QListSpecialMethods<T> {
    // ...
};

template <> struct QListSpecialMethods<QString> {
public:
    inline void sort(Qt::CaseSensitivity cs = Qt::CaseSensitive);
    inline int removeDuplicates();
    inline QString join(const QString &sep) const;
    inline QStringList filter(const QString &str, Qt::CaseSensitivity cs = Qt::CaseSensitive) const;
    inline QStringList &replaceInStrings(const QString &before, const QString &after, Qt::CaseSensitivity cs = Qt::CaseSensitive);
    // ...
};

Bindgen doesn't consider template specializations at the moment. That said, all these methods can be reimplemented on Crystal easily, since we have Enumerable.

If passing data to Qt is all that's needed, Bindgen master should be enough; wrapping QStringList normally gives a default constructor and #<<. This means you can do the following:

classes:
  QStringList: StringList
  # ...
Qt::Completer.new(Qt::StringList{"Option 1", "Option 2"}, parent)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants