End to End GUI Development with Qt5
上QQ阅读APP看书,第一时间看更新

Creating views

In cm-ui, right-click on views.qrc and select Add New…. Select Qt > QML File and click on Choose...:

Create the SplashView.qml file in cm-ui/ui/views. Repeat this process until you’ve created all the following views:

Edit views.qrc in the Plain Text Editor as we have done previously. You will see that our new views have been added to a new qresource block with the default prefix of the following:

<RCC>
 <qresource prefix="/views">
 <file alias="MasterView">views/MasterView.qml</file>
 </qresource>
 <qresource prefix="/">
 <file>views/SplashView.qml</file>
 <file>views/DashboardView.qml</file>
 <file>views/CreateClientView.qml</file>
 <file>views/EditClientView.qml</file>
 <file>views/FindClientView.qml</file>
 </qresource>
</RCC>

Also note that the Projects navigator is a bit of a mess:

Move all the new files into the “/views” prefix block and remove the “/” block. Add an alias for each of the new files:

<RCC>
 <qresource prefix="/views">
 <file alias="MasterView.qml">views/MasterView.qml</file>
 <file alias="SplashView.qml">views/SplashView.qml</file>
 <file alias="DashboardView.qml">views/DashboardView.qml</file>
 <file alias="CreateClientView.qml">views/CreateClientView.qml</file>
 <file alias="EditClientView.qml">views/EditClientView.qml</file>
 <file alias="CreateAppointmentView.qml">views/CreateAppointmentView.qml</file>
 <file alias="FindClientView.qml">views/FindClientView.qml</file>
 </qresource>
</RCC>

As soon as you save these changes, you should see the navigator clean right up: