jerous86 / nimqt

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

Can't compile simple example with Nim 2.0.0 #42

Open hansdampfinger666 opened 5 months ago

hansdampfinger666 commented 5 months ago

I am getting the following error message when compiling your first example (based on examples/hello.nim, https://github.com/jerous86/nimqt#simple-example):

Hint: used config file '/home/al/.choosenim/toolchains/nim-2.0.0/config/nim.cfg' [Conf]
Hint: used config file '/home/al/.choosenim/toolchains/nim-2.0.0/config/config.nims' [Conf]
.......................................................................................................................................
/home/al/.nimble/pkgs2/nimqt-0.1-fad00729be543f3dceac291586d853b3c0a765ac/nimqt/qtwidgets/qlayoutitem.nim(8, 83) Error: invalid indentation

Which is weird because I think that code should only be compiled if I was using a Nim version below 2.0.0.

Got this code snippet in my nimqt/qtwidgets/qlayoutitem.nim file, which seems old, looking at your repo? I followed your install steps exactly.

# Disable 'Warning: type pragmas follow the type name; this form of writing pragmas is deprecated'
{.push warning[Deprecated]: off.}
when (NimMajor, NimMinor, NimPatch) < (1, 9, 0):
    type
        # Classes found in the C++ code
        # COMPLAINS HERE
        QLayoutItem* {.header:headerFile,importcpp:"QLayoutItem" ,pure.} = object {.inheritable.}
        QSpacerItem* {.header:headerFile,importcpp:"QSpacerItem" ,pure.} = object of QLayoutItem
        QWidgetItem* {.header:headerFile,importcpp:"QWidgetItem" ,pure.} = object of QLayoutItem
        QWidgetItemV2* {.header:headerFile,importcpp:"QWidgetItemV2" ,pure.} = object of QWidgetItem
elif (NimMajor, NimMinor, NimPatch) >= (1, 9, 0):
    type
        # Classes found in the C++ code
        QLayoutItem* {.header:headerFile,importcpp:"QLayoutItem" ,pure,inheritable.} = object
        QSpacerItem* {.header:headerFile,importcpp:"QSpacerItem" ,pure.} = object of QLayoutItem
        QWidgetItem* {.header:headerFile,importcpp:"QWidgetItem" ,pure.} = object of QLayoutItem
        QWidgetItemV2* {.header:headerFile,importcpp:"QWidgetItemV2" ,pure.} = object of QWidgetItem
{.push warning[Deprecated]: on.}

As your example stated I tried to compile the code snippet with:

nim cpp src/qt_test.nim

I'm on EndeavourOS with qt6-base 6.6.1-3 installed. Nim 2.0.0, nimble v0.14.2.

Martinix75 commented 5 months ago

try to use: ​ nimble install https://github.com/jerous86/nimqt@#head because the version of Nimqt <0.2 is not compiled with Nim 2.0.0 I for safety in the "nim.cf" file make the following modification ... in nim.cfg:

@if not windows:
  nimblepath="/opt/nimble/pkgs2/"
  #nimblepath="/opt/nimble/pkgs/" <-----comment this!
@else:
  # TODO:
@end
nimblepath="$home/.nimble/pkgs2/"
#nimblepath="$home/.nimble/pkgs/" <--- comment this!
jerous86 commented 5 months ago

As Martinix mentioned, you should append @#head to the install instruction. I updated the readme.

hansdampfinger666 commented 5 months ago

Excellent, thanks! Works now.