Sample App: QML LiveView
In short, this lets you navigate through folders on the PlayBook filesystem to find .qml files, and load one. It displays the page defined by that file, and monitors the filesystem for changes to it or any other .qml files in the same folder, reloading and updating the page as it changes.
- Basic app structure using bbpy.app.Application subclass
- simple persistence (save app state on exit, restore on startup)
- basic use of QML
- reorientation via States
- use of component defined in second QML document
- ListView with model populated with data supplied by Python code
- communication between QML and Python using Properties and Signals/Slots
- inter-thread communication (in Python) via Signals/Slots
How to Use It
This is incredibly useful for rapid development and learning of QML. Just save a .qml file over the WiFi or USB connection to your shared folder (e.g. to
\\PLAYBOOKIP\media\misc), then open it using this utility. Make changes from your text editor on the PC, and each time you save the changes the QML LiveView will reload and display the new page within one second.
If you make any errors, an error page will display showing the error message and the location of the error.
Here's how it looks after launching and navigating down through shared/misc/ and some subfolder on a development device. There's no point in showing what happens when you click on
main.qml there, since it would just show the UI with whatever
main.qml defines, and that's got nothing to do with this app...
If you get make an error in the QML source, you'll see something like the following. Note that the current implementation makes temporary copies of the target .qml file, which is why the filename is
_qv_1338943710.qml in the screenshot.
This particular error occurred because
"burgundy" is not a valid value for the
Disclaimer: We're new to PySide. We're new to Qt. We're new to QML. The PlayBook Qt port is still a work in progress. This is our first sample. Be gentle. ;-)
Seriously, the code almost certainly is not yet a good demonstration of how one should actually do some of these things. It looked so useful, however, that we couldn't hold it back just to protect our own egos. And hey, it's open source! Contributions are welcome...