Closed Martinix75 closed 1 year ago
Hi, you can solve it by doing import sequtils
.
Ideally, you should not have to import it manually, but it's an inaccuracy, which I don't know yet how to solve.
Just a random question: is there a reason you prefer using e.g. - useObject label_10
, rather than - newQLabel(Q "foo") as label_10
?
Ok then "Import sequtils" on the main file (I had seen that the import in "qstringlist.nim" and therefore I had not thought of inserting it in the main file!). tnaks!
2 - I prefer to use "UsoBJECT XXX" because in the layer I prefer to insert as few things possible (like various properties that tomorrow I could decide to add), but it is only a mental setting to keep all the statements widget (and eventual properties) .. for me The code thus reads better (I repeat my personal taste).
Thanks again and good day from Andrea
p.s. 2 I added to the main file: import std/[strformat, os, sequtils]
As said in the "Qstriglist.nim" file it is already present ..
export qlist
# Additional code for qtcore/qstringlist
import sequtils
proc newQStringList*(): QStringList = QStringList()
but now i have a new error:
but now I get the following mistake ..
/home/andrea/ownCloud/In_Sviluppo/NimQt/Gui2_6_madreFx.nim(71, 35) template/generic instantiation of `insertAllSlotImplementations` from here
/home/andrea/ownCloud/In_Sviluppo/NimQt/Gui2_6_madreFx.nim(37, 38) Error: type mismatch: got <seq[QString]>
but expected one of:
proc newQList[T](): QList[T]
first type mismatch at position: 1
extra argument given
proc newQList[T](size: cint): QList[T]
first type mismatch at position: 1
required type for size: cint
but expression '
type
OutType`gensym36 = typeof(
block:
var it: typeof(items(@["Arial", "NewTimes", "Carlito"]), typeOfIter)
newQString(it), typeOfProc)
block:
let :tmp_469762569 = @["Arial", "NewTimes", "Carlito"]
template s2_469762570(): untyped =
:tmp_469762569
var i`gensym36 = 0
var result`gensym36 = newSeq(len(:tmp_469762569))
for it in items(:tmp_469762569):
result`gensym36[i`gensym36] = newQString(it)
i`gensym36 += 1
result`gensym36' is of type: seq[QString]
proc newQList[T](size: cint; t: T): QList[T]
first type mismatch at position: 1
required type for size: cint
but expression '
type
OutType`gensym36 = typeof(
block:
var it: typeof(items(@["Arial", "NewTimes", "Carlito"]), typeOfIter)
newQString(it), typeOfProc)
block:
let :tmp_469762569 = @["Arial", "NewTimes", "Carlito"]
template s2_469762570(): untyped =
:tmp_469762569
var i`gensym36 = 0
var result`gensym36 = newSeq(len(:tmp_469762569))
for it in items(:tmp_469762569):
result`gensym36[i`gensym36] = newQString(it)
i`gensym36 += 1
result`gensym36' is of type: seq[QString]
expression: newQList[QString] do:
type
OutType`gensym36 = typeof(
block:
var it: typeof(items(@["Arial", "NewTimes", "Carlito"]), typeOfIter)
newQString(it), typeOfProc)
block:
let :tmp_469762569 = @["Arial", "NewTimes", "Carlito"]
template s2_469762570(): untyped =
:tmp_469762569
var i`gensym36 = 0
var result`gensym36 = newSeq(len(:tmp_469762569))
for it in items(:tmp_469762569):
result`gensym36[i`gensym36] = newQString(it)
i`gensym36 += 1
result`gensym36
andrea@tec-martin:~/ownCloud/In_Sviluppo/NimQt>
It seems that "qstrringlist" desire argument @[string], while "qlist" desire [qstring] (and they do not talk :))
type
# Classes and enums found in the C++ code
QStringList* {.header:headerFile,importcpp:"QStringList" ,pure.} = object of QList[QString] # --> Qstring
{.push warning[Deprecated]: on.}
export qlist
# Additional code for qtcore/qstringlist
import sequtils
proc newQStringList*(): QStringList = QStringList()
# Making it a template for recursive module dependency reasons ...
template newQStringList*(xs:seq[string]): QStringList = newQList[QString](xs.mapIt(newQString(it))) #--> seq[string]
Yes, my mistake. I should've tested my solution.
It should now work (and the import sequtils
is not necessary anymore)
great! Now it works perfectly! Thank you. To the next problem :)
Sorry, but it's always me! :( I have a problem on creating "qstyringlist" I am attaching the program code and error. I don't understand why "Mapit" according to him is not declared.
/home/andrea/.nimble/pkgs/nimqt-0.1/nimqt/qtcore/qstringlist.nim(22, 77) Error: attempting to call undeclared routine: 'mapIt'
As usual, keep in mind that maybe I'm wrong I am! But I seem to pass the parameters correctly! Thanks for your patience and for your great job! Martin A.