'L' Shaped Enter Button



  • Hello all,

    I'm trying to implement a QWERTY keyboard using buttons like below:

    !http://i.imgur.com/AyP3hSSl.png(Screenshot)!

    See the enter button is an 'L' shape. Is this possible?

    Thanks in advance for any help/direction.



  • Hello and welcome to qt-project.org. Where should the L-shaped enter button be? Or is it the inversed L on the bottom right?
    To answer your question: it is basically possible. What are you using for the buttons? If you are using default Rectangles, then you can implement another Rectangle which color is your Backgroundcolor, example:

    @Rectangle {
    width: 200; height: 200
    color: "BLUE"
    Rectangle {
    x: 100
    width: 100; height: 100
    color: parent.parent.color
    }
    }@

    You'll probably need a MouseArea so you have to move the inner Rectangle outside so its also a child of the parent of your mainrectangle and put a mousearea on your mainrectangle. the second rectangle will overlay it and it wont trigger the mousearea.
    Please provide more information for a more helpfull answer.



  • I think the easiest solution is just to combine two MouseAreas:

    @
    import QtQuick 2.0
    Rectangle {
    width: 360
    height: 360
    color: "lightgray"
    Item {
    id: button
    width: 60
    height: 60
    anchors.centerIn: parent
    readonly property color color: mouse1.pressed || mouse2.pressed ? "gray" : "white"
    signal clicked
    onClicked: print("button clicked")
    Rectangle {
    width: 30
    height: 60
    color: button.color
    MouseArea {
    id: mouse1
    anchors.fill: parent
    onClicked: button.clicked()
    }
    Rectangle {
    width: 60
    height: 30
    color: button.color
    anchors.bottom: parent.bottom
    MouseArea {
    id: mouse2
    anchors.fill: parent
    onClicked: button.clicked()
    }
    }
    }
    }
    }
    @

    If you need a button of arbitrary shape, you can also filter the click in the MouseArea:onPressed function and for instance only accept the event if it is inside a certain shape.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.