Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Native Development

Reply
Trusted Contributor
JohnWS
Posts: 117
Registered: ‎02-08-2013
My Device: 9900

Image Button

Hi,

 

I am going to port a qt application I developed to cascades today and would like a bit of advice.

 

In my qt app I had a custom QLabel class which just fired of a mouse event when it was pressed and I could figure out where the element was pressed by that qmouseevent and set it's background image accordingly.

 

How could I do this with cascades as I have quite a few of these custom buttons.

 

any suggestions appreciated.

Please use plain text.
Developer
javayoung
Posts: 313
Registered: ‎05-31-2010
My Device: Alpha 10, Bold 9900, Storm 9530, Tour 9630, Curve 9320, Curve 8900

Re: Image Button

I think that you can use ImageButton instead of QLabel cause ImageButton can automatically change the image by three status : defaultImageSource, pressedImageSource and disabledImageSource so that you don't need to handle of mouse event. I don't whether it can be your choice or not. thanks




p(^_^)q
Good good study, day day up
Please use plain text.
Trusted Contributor
JohnWS
Posts: 117
Registered: ‎02-08-2013
My Device: 9900

Re: Image Button

Thanks javayoung for your reply,

 

I seen ImageButton but I have an image with 5 possible states depending on what area was touched, QLabel worked great for this.

 

anyone know of something simialr for cascades?

Please use plain text.
Developer
javayoung
Posts: 313
Registered: ‎05-31-2010
My Device: Alpha 10, Bold 9900, Storm 9530, Tour 9630, Curve 9320, Curve 8900

Re: Image Button

[ Edited ]

Can you add some rects to overlap those areas once the rect is clicked which can send signal to a slot to change the background image. Similar to this code:

 

Rectangle {
     id: forwarder
     width: 100; height: 100

     signal send()
     onSend: console.log("Send clicked")

     MouseArea {
         id: mousearea
         anchors.fill: parent
         onClicked: console.log("MouseArea clicked")
     }
     Component.onCompleted: {
         mousearea.clicked.connect(send)
     }
 }

 




p(^_^)q
Good good study, day day up
Please use plain text.
Trusted Contributor
JohnWS
Posts: 117
Registered: ‎02-08-2013
My Device: 9900

Re: Image Button

nice idea, I'll see how I get on.

 

Thanks.

Please use plain text.