jerous86 / nimqt

Qt bindings for nim
GNU General Public License v2.0
93 stars 6 forks source link

QLayoutItem 'widget' method? #9

Closed matkuki closed 1 year ago

matkuki commented 1 year ago

Hi,

Is there another way to get the widget reference from a QLayoutItem, as there is seems to be no widget method for it? https://doc.qt.io/qt-5/qlayoutitem.html#widget

Regards

jerous86 commented 1 year ago

Yes, I know. I mentioned this particular example also at the end of the README.md :)

For example, due to recursive module imports not being supported, not all methods are possible, as types inside the method parameter list or return type would result in a loop (e.g. QLayoutItem::widget() is not available, due to the module dependency QLayoutItem -> QWidget -> QLayout -> QLayoutItem)

If it is really required, a solution is to write the imports manually in your own source code. Something like (untested):

import nimqt/[qwidget,qlayoutitem]
proc widget*(this: ptr QLayoutItem): ptr QWidget {.header:headerFile, importcpp:"#.widget(@)".}

But I don't know how to solve this easily in an automatic way. So I'm waiting for nim to add support for recursive module imports. :)

matkuki commented 1 year ago

Ah, right, I forgot. The workaround works for me, thanks 👍👍👍