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
Defined Under Namespace
Classes: SubclassBuilder
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
- #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.
167 168 169 |
# File 'lib/qml/qt_object_base.rb', line 167 def @meta_object end |
Instance Attribute Details
#pointer ⇒ Object
Returns the value of attribute pointer.
171 172 173 |
# File 'lib/qml/qt_object_base.rb', line 171 def pointer @pointer end |
Instance Method Details
#inspect ⇒ Object Also known as: to_s
194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 |
# File 'lib/qml/qt_object_base.rb', line 194 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..name}]" "#<#{classname}:#{__id__} #{property_inspect}>" end |
#managed=(managed) ⇒ Boolean
Sets the management status of the object.
221 222 223 |
# File 'lib/qml/qt_object_base.rb', line 221 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.
214 215 216 |
# File 'lib/qml/qt_object_base.rb', line 214 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.
229 230 231 |
# File 'lib/qml/qt_object_base.rb', line 229 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.
188 189 190 191 192 |
# File 'lib/qml/qt_object_base.rb', line 188 def qml_eval(str) context = Context.for_object(self) fail QMLError, 'belongs to no context' unless context context.eval(self, str) end |