nimqml/examples/slotsandproperties/contact.nim

33 lines
680 B
Nim
Raw Normal View History

2015-09-14 21:38:02 +00:00
import NimQml
QtObject:
type Contact* = ref object of QObject
m_name: string
proc delete*(self: Contact) =
self.QObject.delete
proc setup(self: Contact) =
self.QObject.setup
proc newContact*(): Contact =
new(result, delete)
result.m_name = "InitialName"
result.setup
proc getName*(self: Contact): string {.slot.} =
result = self.m_name
proc nameChanged*(self: Contact, name: string) {.signal.}
proc setName*(self: Contact, name: string) {.slot.} =
if self.m_name == name:
return
2015-09-14 21:38:02 +00:00
self.m_name = name
self.nameChanged(name)
QtProperty[string] name:
read = getName
write = setName
notify = nameChanged