Wiki home

QMLViewerSample

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.

Features Demonstrated

  1. Basic app structure using bbpy.app.Application subclass
  2. simple persistence (save app state on exit, restore on startup)
  3. QML:
    1. basic use of QML
    2. reorientation via States
    3. use of component defined in second QML document
    4. ListView with model populated with data supplied by Python code
  4. communication between QML and Python using Properties and Signals/Slots
  5. 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...

QML Viewer screenshot

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 color property.

QML LiveView error page


Get It

You can find the code in the QMLViewSample/ folder of the repository, and a signed .bar file on our downloads page.

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...

Updated

Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.