Book Image

Learn Qt 5

By : Nicholas Sherriff
Book Image

Learn Qt 5

By: Nicholas Sherriff

Overview of this book

Qt is a mature and powerful framework for delivering sophisticated applications across a multitude of platforms. It has a rich history in the Linux world, is widely used in embedded devices, and has made great strides in the Mobile arena over the past few years. However, in the Microsoft Windows and Apple Mac OS X worlds, the dominance of C#/.NET and Objective-C/Cocoa means that Qt is often overlooked. This book demonstrates the power and flexibility of the Qt framework for desktop application development and shows how you can write your application once and deploy it to multiple operating systems. Build a complete real-world line of business (LOB) solution from scratch, with distinct C++ library, QML user interface, and QtTest-driven unit-test projects. This is a suite of essential techniques that cover the core requirements for most LOB applications and will empower you to progress from a blank page to shipped application.
Table of Contents (11 chapters)

Mastering MVC

Now that our solution structure is in place, we’ll get started on the MVC implementation. As you’ll see, it is very minimal and incredibly easy to set up.

First, expand cm-ui > Resources > views.qrc > / > views, right-click on main.qml, select Rename, and rename the file as MasterView.qml. If you get a message about project editing, just select Yes to continue anyway:

If you do get the error message, the file will still appear as main.qml in the Projects pane, but the file will have been renamed in the filesystem.

Next, edit views.qrc (right-click on it and select Open With > Plain Text Editor). Replace the content as follows:

    <qresource prefix="/views">
        <file alias="MasterView.qml">views/MasterView.qml</file>

If you recall how we load this...