Learn Qt 5: Build modern, responsive cross-platform desktop applications with Qt, C++, and QML by Nicholas Sherriff

Learn Qt 5: Build modern, responsive cross-platform desktop applications with Qt, C++, and QML by Nicholas Sherriff

Author:Nicholas Sherriff [Sherriff, Nicholas]
Language: eng
Format: epub
Publisher: Packt Publishing
Published: 2018-02-08T23:00:00+00:00

If you switch to the Find Client view and back again, you will see that the value is retained, demonstrating the updates are successfully being set in the string decorator.

Our newly bound view isn't exactly overflowing with data just yet, but over the coming chapters, we will add more and more to this view, so let's add a few finishing touches to prepare us.

Firstly, we only need to add another three or four properties to the view, and we'll run out of space as the default size we’ve set for the window is very small, so in MasterView bump the window size up to something comfortable for your display. I'll treat myself and go full HD at 1920 x 1080.

Even with a larger window to work with, we still need to prepare for the possibility of overflow, so we'll add our content to another new element called ScrollView. As its name suggests, it works in a similar way to flow and manages its content based on the space it has available to it. If the content exceeds the available space, it will present scrollbars for the user. It's also a very finger friendly control and on a touch screen, the user can just drag the content rather than having to fiddle around with a tiny scrollbar.

Although we only have one property currently, when we add more, we will need to lay them out so we'll add a column.

Finally, the controls are stuck to the bounds of the view, so we'll add a little gutter around the view and some spacing in the column.

The revised view should look as follows:

import QtQuick 2.9 import QtQuick.Controls 2.2 import CM 1.0 import assets 1.0 import components 1.0

Item { property Client newClient: masterController.ui_newClient

Rectangle { anchors.fill: parent color: Style.colourBackground }

ScrollView { id: scrollView anchors { left: parent.left right: parent.right top: parent.top bottom: commandBar. top margins: Style.sizeScreenMargin } clip: true Column { spacing: Style.sizeScreenMargin width: scrollView.width StringEditorSingleLine { stringDecorator: newClient.ui_name anchors { left: parent.left right: parent.right } } } }

CommandBar { id: commandBar commandList: masterController.ui_commandController.ui_createClientViewContextCommands } }

Build and run, and you should see the nice neat screen margin. You should also be able to resize the window from wide to narrow and see the string editor automatically adjust its layout accordingly.


Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.
Popular ebooks
Deep Learning with Python by François Chollet(10988)
Hello! Python by Anthony Briggs(8647)
The Mikado Method by Ola Ellnestam Daniel Brolund(8567)
Dependency Injection in .NET by Mark Seemann(8205)
Sass and Compass in Action by Wynn Netherland Nathan Weizenbaum Chris Eppstein Brandon Mathis(6893)
The Well-Grounded Java Developer by Benjamin J. Evans Martijn Verburg(6385)
Secrets of the JavaScript Ninja by John Resig & Bear Bibeault(5831)
Secrets of the JavaScript Ninja by John Resig Bear Bibeault(5212)
Jquery UI in Action : Master the concepts Of Jquery UI: A Step By Step Approach by ANMOL GOYAL(5055)
Kotlin in Action by Dmitry Jemerov(3998)
Audition by Ryu Murakami(3548)
Functional Programming in JavaScript by Mantyla Dan(3466)
Learning React: Functional Web Development with React and Redux by Banks Alex & Porcello Eve(2524)
Architecting Modern Java EE Applications: Designing lightweight, business-oriented enterprise applications in the age of cloud, containers, and Java EE 8 by Daschner Sebastian(2108)
React Native - Building Mobile Apps with JavaScript by Novick Vladimir(2068)
PHP 7 Data Structures and Algorithms by Mizanur Rahman(1936)
Writing for the Web: Creating Compelling Web Content Using Words, Pictures and Sound (Eva Spring's Library) by Lynda Felder(1911)
SEO 2018: Learn search engine optimization with smart internet marketing strategies by Adam Clarke(1849)
Rapid Viz: A New Method for the Rapid Visualization of Ideas by Kurt Hanks & Larry Belliston(1783)
JavaScript by Example by S Dani Akash(1772)