0.0
No release in over 3 years
Ruby Bindings for Qt D-Bus.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
 Dependencies

Runtime

 Project Readme

RubyQt6

Ruby Bindings for libQt6, providing access to the Qt framework.

Requirements

Installation

See INSTALL.md for installation instructions.

Usage

require 'qt6/qtwidgets'

# Create a widget inherit from RubyQt6::Bando::<...>, so that we
# can use `q_object` macro to define signals and slots.
class MyWidget < RubyQt6::Bando::QWidget
  q_object do
    signal "quit_clicked()"             # signals are automatically generated by RubyQt6, must not be implemented
    slot "on_slider_value_changed(int)" # slots must be implemented later
  end

  def initialize
    super                               # NOTE: You must call `super` first

    quit = QPushButton.new('Quit')
    quit.set_font(QFont.new('Times', 18, QFont::Bold))

    @lcd = QLCDNumber.new(2)
    slider = QSlider.new(Qt::Horizontal)
    slider.set_range(0, 99)
    slider.set_value(0)

    layout = QVBoxLayout.new
    layout.add_widget(quit)
    layout.add_widget(@lcd)
    layout.add_widget(slider)
    set_layout(layout)

    quit.clicked.connect(self, :quit_clicked)
    slider.value_changed.connect(self, :on_slider_value_changed)
  end

  def on_slider_value_changed(value)
    @lcd.display(value)
  end
end

if __FILE__ == $PROGRAM_NAME
  app = QApplication.new
  widget = MyWidget.new
  widget.quit_clicked.connect(app, :quit)
  widget.show
  app.exec
end

More examples can be found in examples.

Notes

Memory Management

Following types are allocated on the C++ heap when created using .new.

  • QObject and its subclasses except
    • QCoreApplication, QGuiApplication, QApplication
    • QFile
    • QSettings
    • QUiLoader
  • QLayoutItem and its subclasses
  • QGraphicsItem and its subclasses
  • QStandardItem, QListWidgetItem, QTableWidgetItem, QTreeWidgetItem

You need to trigger immediate deletion by calling the #delete_now method if necessary. Or you can call the #delete_later method, which will wait for the next event loop iteration. For QWidget, you can also use #set_attribute(Qt::WA_DeleteOnClose) method.

Compiler Optimize Options

This library does not enable any optimize options by default. You can use RUBYQT6_CXXFLAGS environment variable to customize them. E.g.

RUBYQT6_CXXFLAGS="-Os -fno-fast-math -flto=auto" gem install ruby-qt6-qtwidgets

Use Cases

License

The RubyQt6 library is licensed under the LGPL-3.0-only WITH LGPL-3.0-linking-exception.

You must also meet your Qt license obligations.