Closed Martinix75 closed 30 minutes 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!
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
ok! It was probably a bug in Nim2.0.4! Fixed with 2.0.6 (or precedents at 2.0.4)
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:
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!!!