Clone
2
Window
Maxwell Jeffress edited this page 2025-11-01 16:49:44 +00:00

Window

Quip uses the Quip::Window class to represent a window.

The constructor paramaters are as follows:

Quip::Window(std::string title, int width, int height)

Creating and Modifying Widgets

Widgets are added to the Quip::Window class. If you would like to add a widget to the screen, you can use the addChild(std::string id, Widget::Widget widget) method to add a child widget.

As an example:

Quip::Window window("Quip Window", 800, 600);
window.addChild("hello", Quip::Widget::TextLabel("Hello, World!", 10, 10));

Widgets can be accessed through the getChild(std::string id) method. This returns a pointer to a std::variant which the widget is stored in.

As an example:

Quip::Window window("Quip Window", 800, 600);
window.addChild("hello", Quip::Widget::TextLabel("Hello, World", 10, 10));

auto* widget = window.getChild("hello");
if (widget && std::holds_alternative<Quip::Widget::TextLabel>(*widget)) {
    std::get<Quip::Widget::TextLabel>(*widget).text = "The text updated!";
}

Running the Window

You can run a Quip window like this:

Quip::Window window("Quip Window", 800, 600);
window.run();

Ideally, return window.run() should be the last line in your main function.