Multiple Views per Window System UI Example

Learn how to render a WindowObject using multiple WindowItems.

Introduction

This example shows you how to assign the same WindowObject to multiple WindowItems, resulting in the same surface being rendered multiple times on screen. The example also illustrates the pros and cons of a primary window.

Prerequisites: You're already familiar with the concepts and topics introduced in the Animated Windows System UI Example.

The button on the top left of the screen shows an icon, a cog, for the only built-in application in this example. Overlayed on this icon is the action taken when you click on it. Start is shown when the application is not running, and clicking on it calls ApplicationObject.start. Otherwise, the button shows Stop and the corresponding action is taken when clicked.

When the application starts, its sole window is shown, decorated with a title bar and borders. The title bar displays Primary if WindowItem.primary is true; Secondary otherwise.

Then, comes the name of the application that created the window, which in this case is App1. On the far left of a window's title bar is a minus button (-) that destroys its WindowItem. On the far right, there's a plus (+) button that creates a new WindowItem and assigns the same WindowObject to it. Finally, for secondary WindowItems, there's also a P button on the right of the title bar that sets the primary property of that WindowItem to true.

When you click on a window, its background color turns red. So when you click on the primary WindowItem you'll see that the event reaches the application, since the window's background color becomes red. But if you create one or more secondary WindowItems and click on them, you will notice that these secondary windows don't flash red, as secondary WindowItems do not forward input events to the WindowObjects they render.

Example project @ code.qt.io

© 2021 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.