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

#domain=(name) ⇒ Object


55
56
57
58
59
60
61
62
63
64
# File 'ext/qml/application.c', line 55

static VALUE application_domain(VALUE self, VALUE name) {
    application_t *data;

   	Check_Type(name, T_STRING);
    TypedData_Get_Struct(self, application_t, &data_type, data);
    if (data->application) {
    	qmlbind_application_setorganizationdomain(RSTRING_PTR(name));
    }
	return self;
}

#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.


109
110
111
112
113
# File 'ext/qml/application.c', line 109

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

#icon=(filename) ⇒ Object


66
67
68
69
70
71
72
73
74
75
# File 'ext/qml/application.c', line 66

static VALUE application_seticon(VALUE self, VALUE filename) {
    application_t *data;

   	Check_Type(filename, T_STRING);
    TypedData_Get_Struct(self, application_t, &data_type, data);
    if (data->application) {
    	qmlbind_application_seticon(RSTRING_PTR(filename));
    }
	return self;
}

#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

#name=(name) ⇒ Object


33
34
35
36
37
38
39
40
41
42
# File 'ext/qml/application.c', line 33

static VALUE application_name(VALUE self, VALUE name) {
    application_t *data;

   	Check_Type(name, T_STRING);
    TypedData_Get_Struct(self, application_t, &data_type, data);
    if (data->application) {
    	qmlbind_application_setapplicationname(RSTRING_PTR(name));
    }
	return self;
}

#organization=(name) ⇒ Object


44
45
46
47
48
49
50
51
52
53
# File 'ext/qml/application.c', line 44

static VALUE application_organization(VALUE self, VALUE name) {
    application_t *data;

   	Check_Type(name, T_STRING);
    TypedData_Get_Struct(self, application_t, &data_type, data);
    if (data->application) {
    	qmlbind_application_setorganizationname(RSTRING_PTR(name));
    }
	return self;
}

#process_eventsObject

Processes queued events in the event loop manually. This method is useful when you are combining an external event loop like EventMachine.


119
120
121
122
# File 'ext/qml/application.c', line 119

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