nimqt
nimqt copied to clipboard
QLayout: ambiguous call
Hi,
- OS: Windows 10 x64
- Nim: devel
- Qt: 6.3.1
- nimqt: Github head
I have this code from a couple of months before that used to work without problems:
var layout = newQHBoxLayout()
layout.setContentsMargins(0, 0, 0, 0)
layout.setSpacing(4)
layout.setAlignment(
newQFlags[Qt_AlignmentFlag](AlignLeft) |
newQFlags[Qt_AlignmentFlag](AlignVCenter)
)
var label = newAdvancedTabBarButtonLabel()
label.setObjectName(Q"icon")
layout.addWidget(label) # <-- THE ERROR IS HERE
...
but now the compilation shows:
Error: ambiguous call; both qlayout.addWidget(this: ptr QLayout, w: ptr QWidget)
[proc declared in E:\mytestproject\dependencies\nimqt\qt\6.4.3_most\nimqt\qtwidgets\qlayout.nim(49, 6)]
and qboxlayout.addWidget(this: ptr QBoxLayout, arg_0: ptr QWidget)
[proc declared in E:\mytestproject\dependencies\nimqt\qt\6.4.3_most\nimqt\qtwidgets\qboxlayout.nim(55, 6)]
match for: (ptr QHBoxLayout, ptr AdvancedTabBarButtonLabel)
stack trace: (most recent call last)
...
So I have to do qlayout.addWidget(layout, label) to get it to work.
The ptr AdvancedTabBarButtonLabel is a: inheritQObject(AdvancedTabBarButtonLabel, QLabel)
Any ideas why? Thanks
Hey matkuki,
that's weird. I don't see any significant commits in the last 10 months.
If I look in the code (see relevant part below), I would assume that nim should be able to detect that QBoxLayout version should be taken.
So I assume that something in the nim compiler has changed?
# qlayout.nim
QLayout* {.header:headerFile,importcpp:"QLayout" ,pure.} = object of QLayoutItem
proc addWidget*(this: ptr QLayout, w: ptr QWidget)
# qboxlayout.nim
QBoxLayout* {.header:headerFile,importcpp:"QBoxLayout" ,pure.} = object of QLayout
QHBoxLayout* {.header:headerFile,importcpp:"QHBoxLayout" ,pure.} = object of QBoxLayout
proc addWidget*(this: ptr QBoxLayout, arg_0: ptr QWidget)
So I assume that something in the nim compiler has changed?
I have that suspicion also, will try downgrading Nim and compile with that.
Yes, with Nim 2.0.8 it works without problems! So it is indeed a compiler regression.
Do I close this issue?
Yes, you can close it, unless you can maybe think of a solution. But as there is a workaround, I don't see it as too much of a problem.