[Interest] how to highlight a custome button on key down

Bo Thorsen bo at fioniasoftware.dk
Fri Oct 5 14:32:37 CEST 2012


Den 05-10-2012 13:59, Satya Praveen Ganapathi skrev:
>
> Hi,
>
> I have a custome button "Button.qml" and I'm using this in another qml 
> "menu.qml"
>
> *Button.qml*
>
> Recatangle{
>
> //some properties
>
> Text{
>
> Id:button
>
> //
>
> }
>
> }
>
> *menu.qml*
>
> **
>
> ViewPort{
>
> Item{
>
> //Button.qml
>
> Button{
>
> Id:button1
>
> }
>
> Button{
>
> Id:button2
>
> }
>
> }
>
> }
>
> Now I'm unable to highlight these buttons in "menu.qml".
>
> I want to use an image to highlight these buttons and move the 
> highlight to next button on key down, move to previous button on key 
> up respectively. On pressing "enter" I have to load another qml file.
>
>

You need to add a MouseArea to your button. Something like this should 
do the trick:

Button.qml:

Rectangle {
     color: "green"
     Text {...}
     MouseArea {
         id: mouse
         anchors.fill: parent
         hoverEnabled: true
     }
     Image {
         anchors.fill: parent
         visible: mouse.containsMouse
         source: "images/myhoverbackground.png"
     }
}

This will switch background color from green to the hover image on mouse 
hover.

Bo Thorsen.
Fionia Software - Qt experts for hire.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20121005/000632fa/attachment.html>


More information about the Interest mailing list