1

I am trying to develop for BlackBerry and I am just playing around with it to try and learn the basics.

So this is really simple but how do I launch a new activity using a button?

I have the onClick property in the QML file and I don't know which code to put in the {}'s.

Bojan Kogoj
  • 5,321
  • 3
  • 35
  • 57
user3535901
  • 3,518
  • 2
  • 13
  • 10

1 Answers1

1

It's unclear what exactly do you expect but I'll give you the example of making a new Sheet. Sheets are full screen views that appear on top of your current content and are usually used for creating or editing content or other activities that are not a main focus of your application.

Lets say that you already have a Page with a button on it:

Page {
    Container {
        Button {
            text: "Open sheet"
            onClicked: {

            }
        }
    }
}

Now to open a new Sheet when you click a button you can attach it to existing Page and define its content. After that you just need to call newSheet.open() from the onClicked() method.

Page {
    Container {
        Button {
            text: "Open sheet"
            onClicked: {
                newSheet.open()
            }
        }
    }
    attachedObjects: [
        Sheet {
            id: newSheet
            Page {
                Container {
                    Label {
                        text: "Sheet"
                    }
                    Button {
                        text: "Close sheet"
                        onClicked: newSheet.close()
                    }
                }
            }
        }
    ]
}

That is the example with opening a new Sheet when clicking the button. You should also check Tabs and NavigationPane

pajaja
  • 2,164
  • 4
  • 25
  • 33
  • 1
    While this works, I think he should just use NavigationPane and Page. Sheet is only to be used for form submissions – Bojan Kogoj Jan 10 '15 at 23:37
  • I agree. The question was a bit vague so I wrote the fist thing that came to mind but I agree that NavigationPane is more likely the better choice. The way of defining objects and using them is similar so he can easily change it to what he needs. – pajaja Jan 11 '15 at 01:28
  • How can I make a new QML file launch though? For example I want a button in example1.qml to launch example2.qml. How do I do that? – user3535901 Jan 11 '15 at 14:07