Class: QML::Application
- Inherits:
-
Object
- Object
- QML::Application
- Defined in:
- lib/qml/application.rb,
ext/qml/application.c
Overview
Application represents a Qt application instance. It provides the event loop and manages Application-level configurations.
Instance Method Summary collapse
-
#engine ⇒ Engine
The engine of the application.
-
#exec ⇒ Object
Starts the event loop of the application.
-
#load(data: nil, path: nil) ⇒ Object
Loads a QML file.
-
#load_data(data) ⇒ Object
Loads a QML file from string data.
-
#load_path(path) ⇒ Object
Loads a QML file from a file path.
-
#process_events ⇒ Object
Processes queued events in the event loop manually.
-
#quit ⇒ Object
Quits the application.
-
#root ⇒ Object
The root object created by the root component.
-
#root_component ⇒ Component
The root component of the application that represents the loaded QML file.
Instance Method Details
#engine ⇒ Engine
Returns The engine of the application.
9 10 11 |
# File 'lib/qml/application.rb', line 9 def engine QML.engine end |
#exec ⇒ Object
Starts the event loop of the application. This method never returns until the application quits.
65 66 67 68 69 |
# File 'ext/qml/application.c', line 65
static VALUE application_exec(VALUE self) {
qmlbind_application app = rbqml_get_application(self);
int ret = (int)rb_thread_call_without_gvl((void *(*)(void *))&qmlbind_application_exec, app, RUBY_UBF_IO, NULL);
return INT2NUM(ret);
}
|
#load(data: nil, path: nil) ⇒ Object
Loads a QML file. The loaded component can be accessed by #root_component
25 26 27 28 |
# File 'lib/qml/application.rb', line 25 def load(data: nil, path: nil) @root_component = Component.new(data: data, path: path) @root = @root_component.create end |
#load_data(data) ⇒ Object
Loads a QML file from string data.
32 33 34 |
# File 'lib/qml/application.rb', line 32 def load_data(data) load(data: data) end |
#load_path(path) ⇒ Object
Loads a QML file from a file path.
38 39 40 |
# File 'lib/qml/application.rb', line 38 def load_path(path) load(path: path) end |
#process_events ⇒ Object
Processes queued events in the event loop manually. This method is useful when you are combining an external event loop like EventMachine.
75 76 77 78 |
# File 'ext/qml/application.c', line 75
static VALUE application_process_events(VALUE application) {
rb_thread_call_without_gvl((void *(*)(void *))&qmlbind_process_events, NULL, RUBY_UBF_IO, NULL);
return Qnil;
}
|
#quit ⇒ Object
Quits the application.
48 49 50 |
# File 'lib/qml/application.rb', line 48 def quit QML.qt.quit end |
#root ⇒ Object
Returns The root object created by the root component.
43 44 45 |
# File 'lib/qml/application.rb', line 43 def root @root or fail "QML data or file has not been loaded" end |
#root_component ⇒ Component
Returns The root component of the application that represents the loaded QML file.
17 18 19 |
# File 'lib/qml/application.rb', line 17 def root_component @root_component or fail ApplicationError, "QML data or file has not been loaded" end |