[SailfishDevel] Python and Qt Widgets development possible?

Thomas Perl th.perl at gmail.com
Wed Feb 12 09:32:38 UTC 2014


Hi,

On 2014-02-11 21:15, Dietmar Schwertberger wrote:
> I tried my Maemo/Fremantle app without a theme.
> As I would like to stay compatible to Maemo and Windows, I would 
> prefer the QtWidgets solution for some time.

Even if you were to use QtWidgets (which I strongly suggest not using), 
you would still have to manage Qt 4 vs. Qt 5 differences (as you 
probably won't be able to use Qt 5 on Maemo, and even if, I don't think 
the Maemo 5 themeing has been forward-ported to Qt 5).

You can stay compatible with Maemo 5 and Windows by using QtQuick 2.0 as 
well:

  - For Maemo 5, use pure QtQuick 2.0 (or use the QtQuick 2 port of Qt 
Quick Components[1])
  - For Windows (and Linux, Mac OS X) use Qt Quick Controls[2]

[1] https://github.com/nemomobile/qt-components/tree/qtquick2
[2] 
http://qt-project.org/doc/qt-5.1/qtquickcontrols/qtquickcontrols-index.html

> The major problems:
>  - When I open a second window, on Maemo I use the stacked windows 
> attribute. On Sailfish that's not available, so a second window opens. 
> The second window then is shown on its own in the multitasking view. 
> This could probably be fixed using QStackedWidgets, though.

Don't open a new window; just show the view inside the first window. 
Only having one window open also means that the window manager has a 
much easier time doing memory management, as it doesn't need to keep 
hidden surfaces around, and the toolkit (Qt Scene Graph in the case of 
Qt 5) can presumably do a much better job of not rendering / storing a 
screenful of every page.

This isn't really a Sailfish OS-related "problem", though.

>  - The menu bar is shown just like in Windows not as pulleye. When you 
> open the menu, again a full window is opened.

Don't use menu bars. That's a WIMP[3] paradigm that doesn't necessarily 
apply to touch interfaces.

[3] http://en.wikipedia.org/wiki/WIMP_%28computing%29

> If I had the same problems on Windows, I would assume that I could get 
> the (window) handles of the underlying windows/widgets/whatever and do 
> some win32 calls to fix the problems. Maybe on Sailfish that's 
> possible as well, but there's no documentation... 

Some inspiration for doing cross-platform Python application development 
using Qt 5, Python 3 and PyOtherSide (assuming the subject of this 
threads is still relevant):

  - Core and glue code, plus Desktop and generic QML UI: 
https://github.com/gpodder/gpodder-ui-qml
  - Sailfish UI: https://github.com/gpodder/gpodder-sailfish

The core and glue code (main.py and stuff in common/ in gpodder-ui-qml) 
is used by all UIs. The Desktop UI (desktop/ in gpodder-ui-qml, very 
barebones) uses Qt Quick Controls and gives you native UIs for Linux, 
Mac OS X and Windows. The "generic QML UI" is just using pure QtQuick 
2.0 and can be used on (touch-based) platforms for which you haven't 
written a UI yet. And then for every platform you want to target 
specifically (such as Sailfish OS), just use the common code and write a 
native UI on top of that, with the native components set - that'd be 
Sailfish Silica for Sailfish OS, Ubuntu Components for Ubuntu Touch, 
Cascades on Blackberry 10 [yeah, no qt5 - ignore that for now], etc...

With Qt Quick Controls, the excuse "I want it to also work on the 
Desktop" doesn't work anymore. QML is good.

Awesomest article in that area is probably still the one from Attila, 
which I highly recommend you read:
http://achipa.blogspot.co.at/2011/07/qt-components-story-of-ugly-qwidgetling.html

HTH :)
Thomas


More information about the Devel mailing list