Anchors

One slight problem with our wonderful new SplashView is that it doesn’t actually fill the window. Sure, we can change the 400 x 200 dimensions to 1024 x 768 so that it matches MasterView, but then what happens if the user resizes the window? Modern UI is all about responsive design—dynamic content that can adapt to the display it’s being presented on, so hard-coding properties appropriate for only one platform aren’t ideal. Fortunately, anchors come to our rescue.

Let’s put our trusty old scratchpad project to use and take a look at anchors in action.

Right-click on qml.qrc and add a new AnchorsDemo.qml QML file alongside the existing main.qml file in the scratchpad folder. Don’t worry about subfolders or .qrc prefixes, aliases, or ...

Get Learn Qt 5 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.