jerous86 / nimqt

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

Nim 2.0.4 erroe (nim2.0.0 compile) #46

Closed Martinix75 closed 30 minutes ago

Martinix75 commented 5 days ago

Good morning, how long (I was very busy !!). Today I reinstalled the whole system and tried to fill in a simple gui (test) with Nim 2.0.4 and I get the following error:

/home/andrea/Scaricati/gui1.nim(6, 6) template/generic instantiation of `init` from here
/home/andrea/.nimble/pkgs2/nimqt-0.2.1-277d74164e27b1ff49f223848fe6497b3105a2f0/nimqt.nim(67, 24) Error: cannot open file: nimqt / qtcore / qnamespace

The same program with Nim 2.0.0 compiles perfectly! What has changed ??? Hello by Andrea M. p.s. Also with Nim 2.0.2 compile correctly, only with Nim 2.0.4 non compile!!!

Martinix75 commented 4 days ago

If I put the imports of Nimqt directly. In my file it works!

import os
import nimqt
import nimqt/qdialog
import nimqt/[qpushbutton, qlineedit]
import nimqt/qtcore/qnamespace

nimqt.init

import nimqt/qtcore/qnamespace
discard qnamespace.Qt_Key.Key_Space # avoid unused import warning <-- to file nimqt.nim
import nimqt/qtcore/qstring   #<-- to file nimqt.nim
import nimqt/qtcore/qobject  #<-- to file nimqt.nim
import nimqt/qtcore/qstring   #<-- to file nimqt.nim
import nimqt/qtgui/qevent     #<-- to file nimqt.nim
import nimqt/qtwidgets/qapplication]  #<-- to file nimqt.nim

let app1 = newQApplication(commandLineParams())

let ledit = newQLineEdit(Q"Prima app in Qt")
ledit.setReadOnly(true)
ledit.setDisabled(true)
ledit.setAlignment(newQFlags(Qt_AlignmentFlag.AlignHCenter)) #allinea al centro

inheritQObject(Bottone, QPushButton):
  slot_decl cambia()

let bottone = newBottone() #<-- cosi non funziona lo slot/signal
bottone.setText(Q"Premi Qui")

let finestra: ptr QDialog = newQDialog() #finestra = qDialog
finestra.makeLayout:
  - use_object ledit
  - use_object bottone:
      connect(SIGNAL "clicked()", bottone, SLOT "cambia()") 

proc cambia(this: ptr Bottone) =
  ledit.setText(Q"Hello World!!")

finestra.setWindowTitle(Q"Gui-1")
finestra.setGeometry(600, 500, 250, 150)
finestra.show()
discard app1.exec()

Obviously the same lines are commented on the Init () template! He seems not liked to import the modules into a template!

Martinix75 commented 4 days ago

I solved it just change the "nimqt.nim" file so .. (line 65)

template init*() {.dirty.} = #<--- add pragma {.dirty.}
    {.emit: """
    #include <QtCore/QObject>
    #include <QtCore/QDebug>
    #include "verdigris/wobjectdefs.h"
    #include "verdigris/wobjectimpl.h"

    using namespace Qt;
    """.}

    {.push warning[UnusedImport]: off.}
    import nimqt/qtcore/qnamespace
    discard qnamespace.Qt_Key.Key_Space # avoid unused import warning
    import nimqt/qtcore/qstring
    import nimqt/qtcore/qobject
    import nimqt/qtgui/qevent
    import nimqt/qtwidgets/qapplication
    {.pop.}

byeee by Andrea

Martinix75 commented 30 minutes ago

ok! It was probably a bug in Nim2.0.4! Fixed with 2.0.6 (or precedents at 2.0.4)