I know that touch apps will run on the desktop with the same UI, but I was wondering if it will be possible for a single Ubuntu SDK app to have a multi-window UI with desktop style UI elements when running in desktop mode, while also providing a separate touch UI when running on touch platforms.
Ubuntu – Can a single Ubuntu SDK target touch and desktop with separate layouts
application-developmentqmlubuntu-sdkubuntu-touch
Best Answer
Changing aspects of the layout depending on the size of the window can be accomplished in a number of ways. At the most basic level, you can just set properties to different values based on the dimensions. Here is a minimal example that draws a grey square that turns orange if you make the window bigger:
Run with
qmlscene path/to/file.qml
Of course, if you have more complex elements to your application this can get a bit tedious. To help with this, the Ubuntu Toolkit provides a ConditionalLayout component where you can define different layouts that will be activated when a condition is met. This happens dynamically, and you can see the changes as you resize the window.
Here is a more complex example using
ConditionalLayout
:When in the default phone-like size, it looks like:
When it is expanded to a tablet or desktop-like size, it looks like: