MenuButton.qml Example File

 import QtQuick 2.0

 Rectangle {
   id: button
   // this will be the default size, it is same size as the contained text + some padding
   width: buttonText.width+ paddingHorizontal*2
   height: buttonText.height+ paddingVertical*2

   color: "#e9e9e9"
   // round edges
   radius: 10

   // the horizontal margin from the Text element to the Rectangle at both the left and the right side.
   property int paddingHorizontal: 10
   // the vertical margin from the Text element to the Rectangle at both the top and the bottom side.
   property int paddingVertical: 5

   // access the text of the Text component
   property alias text: buttonText.text

   // this handler is called when the button is clicked.
   signal clicked

   Text {
     id: buttonText
     anchors.centerIn: parent
     font.pixelSize: 18
     color: "black"

   MouseArea {
     id: mouseArea
     anchors.fill: parent
     hoverEnabled: true
     onClicked: button.clicked()
     onPressed: button.opacity = 0.5
     onReleased: button.opacity = 1

Voted #1 for:

  • Easiest to learn
  • Most time saving
  • Best support

Develop Cross-Platform Apps and Games 50% Faster!

  • Voted the best supported, most time-saving and easiest to learn cross-platform development tool
  • Based on the Qt framework, with native performance and appearance on all platforms including iOS and Android
  • Offers a variety of plugins to monetize, analyze and engage users
create apps
create games
cross platform
native performance
3rd party services
game network
level editor
easiest to learn
biggest time saving
best support