Book Image

Qt 5 Projects

By : Marco Piccolino
Book Image

Qt 5 Projects

By: Marco Piccolino

Overview of this book

<p>Qt is a professional cross-platform application framework used across industries like automotive, medical, infotainment, wearables, and more. In this book you’ll initially create a to-do style app by going via all stages for building a successful project. You'll learn basics of Qt's C++ and QML APIs, test-driven development with Qt Test, application architecture, and UIs with Qt Quick &amp; Quick Controls 2.</p> <p>Next, you’ll help two startups build their products. The first startup, Cute Comics, wants to help independent comic creators with a suite of apps that let them experiment with comic pages, image composition, comic dialogues, and scene descriptions.&nbsp; While developing these apps you’ll deepen your knowledge of Qt Quick's layout systems, and see Qt 3D and Widgets in action.</p> <p>The second startup, Cute Measures, wants to create apps for industrial and agricultural sectors, to make sense of sensor data via a monitoring system. The apps should run seamlessly across devices and operating systems like Android, iOS, Windows, or Mac, and be cost-effective by integrating with existing web technologies. You take the role of lead developer and prototype the monitoring system. In doing so you’ll get to know Qt's Bluetooth and HTTP APIs, as well as the Charts and Web Engine UI modules.</p> <p>These projects will help you gain a holistic view of the Qt framework.</p>
Table of Contents (16 chapters)
Title Page
PacktPub.com
Contributors
Preface
Index

Removing a panel from the page


Given what we have done with the previous use case, from a visual point of view, supporting remove panel from page amounts to two activities:

  •  Adding an affordance to the page to trigger the use case (a minus button)
  • Removing an item from the panel's data model

Thanks to the power of Qt Quick, both tasks are pretty trivial. For the first one, we reuse the already created PanelButton by exposing its text property:

// PanelButton.qml
...
Item {
    signal clicked()
property alias text: textItem.text
    ...
    Text {
id: textItem
        ...
    }
    ...
}

Then, we add the instance below panelAdder and expose it:

// ComicPage.qml
...
Item {
    id: page
    ...
    property alias panelAdder: panelAdder
property alias panelRemover: panelRemover
    ...
    PanelButton {
        id: panelAdder
        anchors.right: parent.right
text: "+"
    }
PanelButton {
        id: panelRemover
        anchors.top: panelAdder.bottom
        anchors.right: parent.right
       ...