Open matkuki opened 4 days ago
Hi,
an issue I see is that you should use QString
instead of string
. Does that resolve your issue?
If not, can you give me a full MWE (including the imports etc)?
Here is the code that reproduces the problem:
# Imports
import strformat
import nimqt
import nimqt / [
qlabel,
qlayout,
qboxlayout,
qgroupbox,
qtabwidget,
qdrag,
qmimedata,
qvariant,
]
# nimqt initialization
nimqt.init()
## AdvancedTabBarButton
inheritQObject(AdvancedTabBarButton, QGroupBox):
var name: QString = ""
var title: QString = ""
var image_path: QString = ""
var labels: seq[ptr QLabel] = newSeq()
var value: bool = false
var pressed: bool = false
var dragging: bool = false
var position_cache: QPoint = newQPoint(-9999.cint, -9999.cint)
# Signals
signal signal_click(name: QString, button: int)
signal signal_close(name: QString)
signal signal_drag_start()
# Slots
slot_defer onclick(name: string, button: Qt_MouseButton):
if button == Qt_MouseButton.LeftButton:
if name != "close":
echo "click"
elif name == "close":
echo "close"
nimqt.insertAllSlotImplementations()
an issue I see is that you should use QString instead of string. Does that resolve your issue?
Changing that produces the next problem in the MSVC++ compilation:
nimcache\@merror_reproducing.nim.cpp(60): error C2061: syntax error: identifier 'Qt_MouseButton'
... but why can't I use a string
(or bool
, or ...) in a slot?
Thanks
... but why can't I use a string (or bool, or ...) in a slot?
I think you can use bool etc in a slot.
The string
is not mapped to std::string
, I don't know why. Using QString
bypasses that problem (but that would not be a satisfactory solution)
nimcache\@merror_reproducing.nim.cpp(60): error C2061: syntax error: identifier 'Qt_MouseButton'
I also encounter here an issue with Qt_MouseButton
: error: unknown type name 'Qt_MouseButton'; did you mean 'Qt::MouseButton?
.
If I look in qtcore/qnamespace.nim
, then I find that Qt_MouseButton* {.header:headerFile,importcpp:"Qt::MouseButton".} = enum ...
so I would assume that nim maps Qt_MouseButton
to Qt::MouseButton
, but maybe due to the macros this does not happen.
Did you encounter this also with earlier compiler versions of nim (or I guess you did not have this code when you were using an older version of nim?)
Did you encounter this also with earlier compiler versions of nim (or I guess you did not have this code when you were using an older version of nim?)
Unfortunately no, this is the first time I've used Qt_MouseButton
in a slot. Actually, this is the first time I've used slots with arguments.
Hi,
I'm on Windows x64, Nim devel, nimqt head. This is my object override:
Compilation in Nim succeeds, but the MSVC++ compilation fails with:
The problem is in the
slot_defer
(I triedslot
and it's the same), but I don't know why. Any ideas?