Class: QML::Application

Inherits:
Object
  • Object
show all
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.

See Also:

Instance Method Summary collapse

Instance Method Details

#engineEngine

Returns The engine of the application.

Returns:

  • (Engine)

    The engine of the application.



9
10
11
# File 'lib/qml/application.rb', line 9

def engine
  QML.engine
end

#execObject

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

Parameters:

  • data (String) (defaults to: nil)
  • path (String) (defaults to: nil)

See Also:



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.

See Also:



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.

See Also:



38
39
40
# File 'lib/qml/application.rb', line 38

def load_path(path)
  load(path: path)
end

#process_eventsObject

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;
}

#quitObject

Quits the application.



48
49
50
# File 'lib/qml/application.rb', line 48

def quit
  QML.qt.quit
end

#rootObject

Returns The root object created by the root component.

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_componentComponent

Returns The root component of the application that represents the loaded QML file.

Returns:

  • (Component)

    The root component of the application that represents the loaded QML file.

See Also:



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