jerous86 / nimqt

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

nimQt and nim 2.0.0 #34

Closed Martinix75 closed 8 months ago

Martinix75 commented 10 months ago

Good morning. I've been writing for a long time !!! But in the summer I have very little time to devote to the computer, but luckily the autumn is now about to arrive. I tried Ninqt with Nim 2.0.0, and obviously I don't fill out, I wanted to know if you understand why! I tried to replace for example:

QListWidgetItem* {.header:headerFile,importcpp:"QListWidgetItem" ,pure.} = object {.inheritable.}

with:

QListWidgetItem* {.header:headerFile,importcpp:"QListWidgetItem" ,pure.} = object of RootObj #{.inheritable.}

manually on all mistakes ... a nightmare !! But in the end I get a compilation error:

andrea@tec-martin:~/Scrivania/NimQt>  cd /home/andrea/Scrivania/NimQt
andrea@tec-martin:~/Scrivania/NimQt> nim cpp -r finestra2.nim 
Hint: used config file '/home/andrea/bin/nim/config/nim.cfg' [Conf]
Hint: used config file '/home/andrea/bin/nim/config/config.nims' [Conf]
........................................................................................................................................................................................................................................................................
/home/andrea/.nimble/pkgs/nimqt-0.1/nimqt.nim(65, 24) Warning: imported and not used: 'qnamespace' [UnusedImport]
CC: finestra2.nim
/home/andrea/.cache/nim/finestra2_d/@mfinestra2.nim.cpp: In function ‘void onTextChanged(Receiver*)’:
/home/andrea/.cache/nim/finestra2_d/@mfinestra2.nim.cpp:569:40: error: ‘this_p0’ was not declared in this scope; did you mean ‘this_0’?
  569 |         label__finestra50_u57->setText(this_p0->toPlainText());
      |                                        ^~~~~~~
      |                                        this_0
/home/andrea/.cache/nim/finestra2_d/@mfinestra2.nim.cpp: In function ‘void undoAvailable(Receiver*, bool)’:
/home/andrea/.cache/nim/finestra2_d/@mfinestra2.nim.cpp:592:89: error: ‘this_p0’ was not declared in this scope; did you mean ‘this_0’?
  592 |         colontmpD_ = dollar___OOZOOZOnimbleZpkgsZnimqt4548O49ZnimqtZqtcoreZqstring_u681(this_p0->toPlainText());
      |                                                                                         ^~~~~~~
      |                                                                                         this_0
/home/andrea/.cache/nim/finestra2_d/@mfinestra2.nim.cpp: In function ‘bool event(Receiver*, QEvent*)’:
/home/andrea/.cache/nim/finestra2_d/@mfinestra2.nim.cpp:618:18: error: ‘this_p0’ was not declared in this scope; did you mean ‘this_0’?
  618 |         result = this_p0->parent_event(e_p1);
      |                  ^~~~~~~
      |                  this_0
compilation terminated due to -fmax-errors=3.
Error: execution of an external compiler program 'g++ -c -std=gnu++17 -funsigned-char  -w -fmax-errors=3 -fpermissive -pthread -std=c++17 -I/home/andrea/.nimble/pkgs/nimqt-0.1 -I/usr/include/qt6 -fPIC   -I/home/andrea/bin/nim/lib -I/home/andrea/Scrivania/NimQt -o /home/andrea/.cache/nim/finestra2_d/@mfinestra2.nim.cpp.o /home/andrea/.cache/nim/finestra2_d/@mfinestra2.nim.cpp' failed with exit code: 1

andrea@tec-martin:~/Scrivania/NimQt> 

I don't know if it can be useful! For now hello from Andrea p.s. Other simplest windows, with this change, are also compiled with Nim2.0.0

import os
import nimqt
import nimqt/qdialog
import nimqt/[qtextbrowser, qlineedit]

nimqt.init #inizializza tutto il framekork
let app1 = newQApplication(commandLineParams()) #linea obbligatora (da mettere in inizio) per avviare l'app.

let txb = newQTextBrowser() #creiamo l'oggetto Qtextbroswer

inheritQObject(Pippo, Qlineedit): #qui Pippo ededita da Qlinedit (di fatto pippo è qilinedit) ma dichiariamo gli slot a cui fara capo.
  slot_decl stampa() #dichiara lo slot che andremo a creare (dopo)
  #qui non puoi usare slot, perche la var "cavolo" viene dichiarata dopo.

#let gui: ptr Pippo = newPippo()
let finestra: ptr QDialog = newQDialog() #creamo ( e puntimao) all'oggetto Qdialog cha ci dara dei metodi per la finestra
finestra.makeLayout: #crea il layout Verticale (qVboxLayout)
  - use_object txb #inserisco nel layout vert il Textbrowse (segue loride)
  - newPippo() as cavolo: #inserisco l'ogetto modificato Pippo = Qlinedit) e gli do un alias.
      setFocus() #meto il focus su qlinedit
      connect(SIGNAL "returnPressed()", cavolo, SLOT "stampa()") #quando premo invio chiama lo slot "stampa() priam dicharato

proc stampa(this: ptr Pippo) = #slot che va a chiamare e dichiarato prima in eredità
 echo "ok" #stampa "ok" in consoll
 txb.append(cavolo.text()) #aggiunge qualcosa a Qtextbrosver (in oista)
 cavolo.clear() #cancella la Qlineedit

finestra.setWindowTitle(Q"Calcolatorice") #mette un titolo alla finestra
finestra.show() #mostra la finestra a video
discard app1.exec() #ciclo infinito

this windows run whit Nim 2.0.0!!

jerous86 commented 9 months ago

Hi Andrea, I will not have much time looking into this the coming weeks, but have you tried the latest commit? I.e. installing with nimble install https://github.com/jerous86/nimqt@#head? (Just doing nimble install https://github.com/jerous86/nimqt will not install the latest commit) Does it still occur then?

Martinix75 commented 9 months ago

no! I think I have not tried the latest Commit (Nimble Install https://github.com/jerous86/nimqt@#head) but only with the classic "Nimble Install https://github.com/jerous86/nimqt". On Monday I feel and see what happens (this slate too I can only have a thousand things to do). I'll let you know, for now thanks! Hello from Andrea

Martinix75 commented 9 months ago

I tried to install nimqt with Nimble Install https://github.com/jerous86/nimqt@#head. (in .nimble/pkgs2/nimq-0.2.0 ...) but when I go to fill in it goes to take the library in ./nimble/pkg/nimq-0.1-0. (although using nim2) What do I have to do to tell him to use the correct package?

Martinix75 commented 9 months ago

I solved by erasing the "pkgs" folder now it seems to copy correctly ... but .... Everyone seems to go and get now, the correct package (ver 020) except one, which I don't know why it still looks for the package in pksg/nimq-01)

import os
import nimqt
import nimqt/qdialog
import nimqt/[qtextbrowser, qlineedit]

nimqt.init #inizializza tutto il framekork
let app1 = newQApplication(commandLineParams()) #linea obbligatora (da mettere in inizio) per avviare l'app.

let txb = newQTextBrowser() #creiamo l'oggetto Qtextbroswer

inheritQObject(Pippo, Qlineedit): #qui Pippo ededita da Qlinedit (di fatto pippo è qilinedit) ma dichiariamo gli slot a cui fara capo.
  slot_decl stampa() #dichiara lo slot che andremo a creare (dopo)
  #qui non puoi usare slot, perche la var "cavolo" viene dichiarata dopo.

#let gui: ptr Pippo = newPippo()
let finestra: ptr QDialog = newQDialog() #creamo ( e puntimao) all'oggetto Qdialog cha ci dara dei metodi per la finestra
finestra.makeLayout: #crea il layout Verticale (qVboxLayout)
  - use_object txb #inserisco nel layout vert il Textbrowse (segue loride)
  - newPippo() as cavolo: #inserisco l'ogetto modificato Pippo = Qlinedit) e gli do un alias.
      setFocus() #meto il focus su qlinedit
      connect(SIGNAL "returnPressed()", cavolo, SLOT "stampa()") #quando premo invio chiama lo slot "stampa() priam dicharato

proc stampa(this: ptr Pippo) = #slot che va a chiamare e dichiarato prima in eredità
 echo "ok" #stampa "ok" in consoll
 txb.append(cavolo.text()) #aggiunge qualcosa a Qtextbrosver (in oista)
 cavolo.clear() #cancella la Qlineedit

finestra.setWindowTitle(Q"Calcolatorice") #mette un titolo alla finestra
finestra.show() #mostra la finestra a video
discard app1.exec() #ciclo infinito

And I can't understand why, and what different in this program than others !! (or what I'm wrong).

Martinix75 commented 9 months ago

This also does not work (it seems there is a problem on icons)

import os
import nimqt
import nimqt/[qlabel, qpushbutton, qspinbox,  qicon]
import nimqt/[qwidget, qboxlayout, qgridlayout, qdialogbuttonbox]

nimqt.init

let pwmApp = newQApplication(commandLineParams())
let lab1 = newQLabel(Q"Set PWM")
let sbx1 = newQSpinBox()
sbx1.setRange(0,100)
sbx1.setsuffix(Q" %")
let lab2 = newQLabel(Q"Set Time")
let sbx2 = newQSpinBox()
sbx2.setSuffix(Q" Min")
sbx2.setMinimum(0)

let sbx3 = newQSpinBox()
sbx3.setSuffix(Q" Sec")
sbx3.setRange(0, 59)

inheritQObject(Pippo, QObject):
  slot_decl io()

#let icona = newQIcon(Q"eco.png") #<=========== PROBLAM!!!!!!!!!!
echo "ciao"
let gui: ptr Pippo = newPippo()

let finestra: ptr QWidget = newQWidget()
finestra.makeLayout: #cosi sembra un layout verticale...
  - newQWidget():
    - newQHBoxLayout():
      -  use_object lab1
      - use_object sbx1
  - newQWidget():
    - newQHBoxLayout():
      - use_object lab2
      - use_object sbx2
      - use_object sbx3
  - newQDialogButtonBox(newQFlags(QDialogButtonBox_StandardButton.Ok)|newQFlags(QDialogButtonBox_StandardButton.Close), finestra):
      connect(SIGNAL "rejected()", finestra, SLOT "close()")
      connect(SIGNAL "accepted()", gui, SLOT "io()")

proc io(this: ptr Pippo) =
  echo "Valore Accettato...."
  echo (sbx1.text)
  echo (sbx2.text)
  echo (sbx3.text)

finestra.setWindowTitle(Q"TestPWM")
finestra.setGeometry(160, 140, 300, 100)
#finestra.setWindowIcon(icona)   #<========= PRPBLEM
finestra.show()
discard pwmApp.exec()

Sorry if I put some things together, but I didn't want to open 100 Uisses! Bye!

jerous86 commented 8 months ago

Hi Andrea, it's ok if you open a lot of issues. That makes it a bit easier for me to track things.

I'm not sure I understand all the problems you are listing. If it's still not working, could you give me maybe a minimal example that goes wrong, together with an explanation of what goes wrong?

I solved by erasing the "pkgs" folder now it seems to copy correctly ... but .... Everyone seems to go and get now, the correct package (ver 020) except one, which I don't know why it still looks for the package in pksg/nimq-01)

I tried to run the program you give there, and it runs without any compilation error on my laptop.

Regarding the problem with the icon

#let icona = newQIcon(Q"eco.png") #<=========== PROBLAM!!!!!!!!!!

For me it compiles when I do


let icona = newQIcon(path)```
So it might be something related to the nim compiler.
Martinix75 commented 8 months ago

Sorry if I answer slow, but I'm working on things and time is always little. No now (with Nimqt 0.2.0) fill out everything perfectly. For the icon discourse, Aporo another post. So this can close it, and open a new one.