We have moved to a new Sailfish OS Forum. Please start new discussions there.
8

ButtonLayout example syntax error [answered]

Tracked by Jolla (In release)

asked 2019-12-14 23:39:03 +0200

Spam Hunter gravatar image

updated 2019-12-16 16:27:47 +0200

With respect to the documentation of a ButtonLayout example for SFOS;

 import QtQuick 2.2
 import Sailfish.Silica 1.0

 Page {
     ButtonLayout {
         anchors.width: parent.width   // <---- this line
         Button {
             text: "Button1"
         }
         Button {
             text: "Button2"
         }
         Button {
             text: "Button3"
         }
     }
 }

This throws an error in the SDK, as I would expect it to.....anchors.width?, clearly this should be width: parent.width, then the example works.

Also, the example, along with many others, are somewhat lacking any context. Many use cases for buttons might be on pages in apps or settings, so why not set an example of how you could arrange 3 buttons on a page, like the following;

import QtQuick 2.0
import Sailfish.Silica 1.0

Page {
    id: page

    SilicaFlickable {
        anchors.fill: parent
        Column {
            id: column
            width: page.width
            spacing: Theme.paddingLarge

            PageHeader { title: qsTr("Button layout") }

            ButtonLayout {
                width: parent.width
                Button {
                    text: "Button 1"
                    onClicked: {
                        console.log("Button 1 clicked")
                    }
                }
                Button {
                    text: "Button 2"
                    onClicked: {
                        console.log("Button 2 clicked")
                    }
                }
                Button {
                    text: "Button 3"
                    onClicked: {
                        console.log("Button 3 clicked")
                    }
                }
            }
        }
    }
}
edit retag flag offensive reopen delete

The question has been closed for the following reason "the question is answered, an answer was accepted" by Spam Hunter
close date 2020-04-27 12:14:24.938043

Comments

1

Good catch, thank you! Actually ButtonLayout, as a layout, does not need size bindings. so it will be fixed by simply removing the line. More complex example would not be suitable here, according to Silica devs: "We should do more full-screen view layout examples, but maybe not in API documentation, there short snippets that you can easily copy&paste to your project are the better."

martyone ( 2020-01-16 14:19:14 +0200 )edit

1 Answer

Sort by » oldest newest most voted
1

answered 2020-04-27 10:26:04 +0200

jovirkku gravatar image

Fixed in OS release 3.3.0.

edit flag offensive delete publish link more

Comments

Thanks all, a quick squint at the page, I can see the error has now been rectified!

Spam Hunter ( 2020-04-27 12:14:06 +0200 )edit

Question tools

Follow
4 followers

Stats

Asked: 2019-12-14 23:39:03 +0200

Seen: 356 times

Last updated: Apr 27 '20