Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

qdialoagBox #13

Closed
Martinix75 opened this issue Feb 6, 2023 · 4 comments
Closed

qdialoagBox #13

Martinix75 opened this issue Feb 6, 2023 · 4 comments

Comments

@Martinix75
Copy link

Good evening,
I'm playing a little with Nimqt and I must say it's fun.
But I have a small problem with "qdiaogbox" that I didn't understand very well what to pass. For now I have made so I am attaching my program and if you make me understand the error I will be very happy :) good evening!

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)

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

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(QDialogButtonBox_StandardButtons[1], finestra) #<-- ?????????

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

Thanks for your help by A.Martin

@jerous86
Copy link
Owner

jerous86 commented Feb 6, 2023

I think the following is what you want to do? I don't get the buttons, but not sure how they work in Qt.

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(Yes)|newQFlags(No), finestra) #<-- ?????????

@Martinix75
Copy link
Author

So not a mistake in compilation, but I don't see the buttons (not even me) I work on it on a while and I see if I solve, for now thanks!

@Martinix75
Copy link
Author

Martinix75 commented Feb 7, 2023

I understood the problem !!!
The problem is in the "qdialobuttonbox.nim" file.
Specifically in the "Enum"
wrong:
[QDialogButtonBox_StandardButton* {.header:headerFile,importcpp:"QDialogButtonBox::StandardButton".} = enum NoButton = 0, Ok = 0x1, Save = 0x2, SaveAll = 0x3,
Open = 0x4, Yes = 0x5, YesToAll = 0x6, No = 0x7, NoToAll = 0x8,
Abort = 0x9, Retry = 0xa, Ignore = 0xb, Close = 0xc, Cancel = 0xd,
Discard = 0xe, Help = 0xf, Apply = 0x10, Reset = 0x11, RestoreDefaults = 0x12,
FirstButton = 0x13, LastButton = 0x14]

I corrected it (only partially .. for testing, in this way ..)
QDialogButtonBox_StandardButton* {.header:headerFile,importcpp:"QDialogButtonBox::StandardButton".} = enum NoButton = 0, Ok = 0x400, Yes = 0x4000,
No = 0x10000

as indicated in the following table
https://doc.qt.io/qt-6/qdialogbuttonbox.html

By putting the correct numbers in Enum the buttons appear!

I did the "fork" of your project, if I can (time permitting) I see if I can modify and make a Commit.
Hi from Andrea

@jerous86
Copy link
Owner

jerous86 commented Feb 7, 2023

Thank you very much for finding the solution!

Your patch is correct, but the issue was in the code that generated the bindings (and so there are many more enums that were not correct), while yours only fixes a single file, so I will not pull it.
But your help is much appreciated! :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants