Class: QML::QtObjectBase
- Inherits:
-
Object
- Object
- QML::QtObjectBase
- Includes:
- Dispatchable, Reactive::Object
- Defined in:
- lib/qml/qt_object_base.rb
Overview
QtObjectBase is the base class for Qt object wrappers.
In ruby-qml you can access the followings of Qt objects in Ruby.
-
Properties as Reactive::Property
-
Signals as Reactive::Signal
-
Q_INVOKABLE methods, slots and QML methods as Ruby methods
Properties and signals support is provided by Reactive::Object.
While their names are camelCase in Qt, ruby-qml aliases them as underscore_case.
Direct Known Subclasses
Class Attribute Summary collapse
-
.meta_object ⇒ Object
Returns the value of attribute meta_object.
Instance Attribute Summary collapse
-
#pointer ⇒ Object
readonly
Returns the value of attribute pointer.
Instance Method Summary collapse
- #custom_data ⇒ Object private
- #inspect ⇒ Object (also: #to_s)
-
#managed=(managed) ⇒ Boolean
Sets the management status of the object.
-
#managed? ⇒ Boolean
Whether the object is managed by Ruby and QML and garbage collected when no longer used.
-
#prefer_managed(managed) ⇒ Boolean
Sets the management status of the object in safer way.
-
#qml_eval(str) ⇒ Object
Evaluates a JavaScript expression on the QML context of the object.
Methods included from Reactive::Object
included, #initialize, #properties, #property, #signal, #signals
Methods included from Reactive::Object::ClassMethods
#alias_property, #alias_signal, #instance_properties, #instance_property, #instance_signal, #instance_signals, #on, #on_changed, #property, #signal, #variadic_signal
Methods included from Dispatchable
Class Attribute Details
.meta_object ⇒ Object
Returns the value of attribute meta_object.
37 38 39 |
# File 'lib/qml/qt_object_base.rb', line 37 def end |
Instance Attribute Details
#pointer ⇒ Object
Returns the value of attribute pointer.
41 42 43 |
# File 'lib/qml/qt_object_base.rb', line 41 def pointer @pointer end |
Instance Method Details
#custom_data ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
45 46 47 |
# File 'lib/qml/qt_object_base.rb', line 45 def custom_data @custom_data ||= {} end |
#inspect ⇒ Object Also known as: to_s
69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 |
# File 'lib/qml/qt_object_base.rb', line 69 def inspect klass = self.class property_inspect = klass.instance_properties.sort .reject { |name| klass.instance_property(name).alias? } .map do |name| "#{name}=" + begin property(name).value.inspect rescue ConversionError "<unsupported type>" end end .join(' ') classname = klass.name || "[class for #{klass.meta_object.name}]" "#<#{classname}:#{__id__} #{property_inspect}>" end |
#managed=(managed) ⇒ Boolean
Sets the management status of the object.
96 97 98 |
# File 'lib/qml/qt_object_base.rb', line 96 def managed=(managed) pointer.managed = managed end |
#managed? ⇒ Boolean
Returns whether the object is managed by Ruby and QML and garbage collected when no longer used.
89 90 91 |
# File 'lib/qml/qt_object_base.rb', line 89 def managed? pointer.managed? end |
#prefer_managed(managed) ⇒ Boolean
Sets the management status of the object in safer way. Objects that are created by QML will remain managed and objects that have parents will remain unmanaged.
104 105 106 |
# File 'lib/qml/qt_object_base.rb', line 104 def prefer_managed(managed) pointer.prefer_managed managed end |
#qml_eval(str) ⇒ Object
Evaluates a JavaScript expression on the QML context of the object. Fails with QML::QMLError when the object is not created by QML and does not belong to any context.
63 64 65 66 67 |
# File 'lib/qml/qt_object_base.rb', line 63 def qml_eval(str) context = Context.for_object(self) fail QMLError, 'belongs to no context' unless context context.eval(self, str) end |