3

I'm trying to make an app that count how many times you've clicked the button in blackberry 10

so i'm trying to int a value that will increase by 1 when you click the button

import bb.cascades 1.2

Page {
    Container {
        ImageButton {

            defaultImageSource: "asset:///item_XS_6405840_3762396.jpg"
            onClicked: { 
                count.setText(count + 1)
            }
            onTouch: {
                count.setText(count + 1)
            }
        }
        Label {
            text: "you've clicked:"
        }

        Label {
            id: count
            text: 0
        }

        Button {
            id: reset
            text: "reset"
            onClicked: {
                count = 0;
            }
        }
    }
}

I only have knowledge in java. thanks for helping

Bojan Kogoj
  • 5,321
  • 3
  • 35
  • 57
  • 4
    To the people who put this on hold, are you sure you know BlackBerry QML well enough to judge if this question has sufficient information? I don't see any of you actively answering BlackBerry questions, so I am not sure that in fact you even know as much as the OP. – Peter Strange Mar 23 '14 at 18:11
  • To the OP. Be careful what tags you associate with a question. In this case you attached the C++ tag, when the code you have posted is entirely QML. I have removed that tag. – Peter Strange Mar 23 '14 at 18:15
  • 1
    The issue here is that you are trying to use a Label field as a counter. A Label field contains text, not an integer value. All you need to do here to get this working is to create an integer property associated within this page, and use it as your counter. Call this property clickCounter, then set the count field value using something like count.setText(++clickCounter); I'd work an example and post it, but this question has been put on hold. Hopefully this is enough. More on properties here: http://qt-project.org/doc/qt-4.8/qdeclarativeintroduction.html – Peter Strange Mar 23 '14 at 18:23
  • 1
    Peter I have notice this happening more and more on SO, to the point where it is having a significant impact on the usefulness of the site (at least for BB developers). It is certainly reducing my motivation to come here. @jonrsharpe et al, this question can be easily answered as it is. There is sufficient information to answer the question. Please remove the hold so Peter, I or someone else can help the OP. – Richard Mar 28 '14 at 16:53
  • @user3451982 and anyone else interested, rather than make you wait while the SO political situation gets sorted out there is an answer to your question here: http://www.hrbuckley.net/2014/03/qml-button-click-counter.html – Richard Mar 28 '14 at 18:06
  • I don't get. The question is logical and very easy to answer. OP is just a beginner – Bojan Kogoj Mar 29 '14 at 17:40

0 Answers0