Basic widgets

As basic widgets, we consider the basic building blocks to organize your user-interface and visualize information. Some of the widgets listed here correspond to HTML elements, while others have a non-trivial implementation.

They are often used to build more complex composite widgets. Wt's widgets all inherit from WWidget. Widgets are rendered by inserting them in the widget tree hierarchy. You have the following possibilities to structurally organize your widgets:

  • Adding a widget to a WContainerWidget (or more conveniently, passing the container as a parent during construction). You'll need to use CSS to arrange your widgets inside the container widget.
  • Binding a widget in a WTemplate. This is the most natural way of organizing your widgets if you are using CSS for layout.
  • By adding a widget to a layout manager layout manager, you can circumvent the limitations of CSS-based layout managenet, and benefit from splitters to allow the user to adjust the layout.

User interaction can be implemented using Wt's signal/slot implementation. You may respond to CGI post-backs or JavaScript events by connecting C++ method invocations to corresponding signals exposed by widgets. For example, the descendants of WInteractWidget emit events such as key events (keyPressed(), keyWentDown(), keyWentUp(), ...) and mouse events (clicked(), doubleClicked(), but also mouseWentOver() and mouseMoved()). Except for mouse clicks, these events can only be handled when JavaScript is available.

In this widget demo application, occasionally selected events are demonstrated and shown in the event window at the bottom of the browser window. The reference manual provides a complete reference API reference for each widget, including all events implemented by a widget.

Basic widgets have only a limited amount of styling. This allows you to customize the look of these widgets using CSS to fit within your design.

Related topics: Events and Style and Layout.

Events will be shown here.