qt-light/examples/custom-widgets/README.md
Jaidyn Ann 1704d392e8 Add “custom-widgets” example
This small example demonstrates defining and
binding to your own subclass of a QT widget.
2024-02-04 15:10:37 -06:00

14 lines
658 B
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# “Goodbye” example
This is a bare-minimum example egg that shows how one can define their own
custom QT widgets and bind to their methods in a way compatible with qt-light.
It defines an `OurButton` C++ class that is derived from
[`QPushButton`](https://doc.qt.io/qt-6/qpushbutton.html) with one change:
It adds a `SayGoodbye()` method that changes the buttons label to “Goodbye”.
We write a wrapper C-function `gb_saygoodbye()` and bind this function into
our `goodbye-widgets` module under the name `gb:saygoodbye`. It is run on the
button (originally labelled “Quit” in the `goodbye.ui` file), so changing its
text to “Goodbye”.