Introduction to Qt / QML (Part 10) - Anchor Layout

Опубликовано: 07 Октябрь 2024
на канале: KDAB
24,779
422

Any user interface is built by positioning controls on the screen. While we can easily change the x/y coordinates of a given item, this approach doesn't quite scale when building an entire interface. This is where layout managers enter the game: elements (and properties) that automatically manage the position and the sizing of other elements.

This video introduces the simplest and yet most commonly used layouting system available in Qt Quick: anchor layouts. Anchors allow us to "glue" a side (left/right/top/bottom) of an element to a side of another element. This makes it super easy to place two elements side by side, or left/right-align an element inside its parent. The center and fill anchor layouts are also discussed here.

Some of the other layouting solutions available in Qt Quick are:
Positioners (Row, Column, etc.): https://doc.qt.io/qt-5/qtquick-positi...

Qt Quick Layouts: https://doc.qt.io/qt-5/qtquicklayouts...

Placing elements manually by changing their x/y/width/height coordinates: https://doc.qt.io/qt-5/qtquick-visual...

The example code showcased in this video is available here: https://github.com/KDAB/kdabtv

About the host:
The video is presented by Jesper Pedersen, who started with Qt back when Qt was widgets only and the version was 1.44, which gives him 21 years of experience with Qt. Since 2000 he has taught almost 100 Qt classes, ranging from Qt Widgets to QML. Heck, Jesper even taught a few classes on QTopia Core — Trolltech's initial attempt at creating a phone stack. Today Jesper holds a fancy business title, but that doesn't prevent him from coding both in his job and in his spare time.

About KDAB:
KDAB offers experienced software experts to help you deliver functional, high-performing and innovative software across embedded, mobile and desktop platforms for projects using C++, Qt, QML/Qt Quick, OpenGL, Qt 3D and more. https://www.kdab.com/software-services

KDAB experts regularly take time out to deliver KDAB’s world class training, in-house or at open enrolment courses around the world. We are the market leaders for training in Qt, OpenGL and C++.

Contact us to find out more at [email protected] or visit our website: https://www.kdab.com/software-service...

We are about 90 people, located all around the world. Our Head Office is in Sweden and we have other offices in Germany, France, the UK and the USA. https://www.kdab.com/about/contact/