bkh6722
bkh6722

Reputation: 173

Clickable rectangular in QML

I have created a rectangular as an alternative for button (because I can't use standard buttons for no reason). Using Qt-Designer I put on the rectangular MouseArea, so that I could make the rectangular clickable. Problem, that demotivates me, is that it doesn't work either.

import QtQuick 2.12
import QtQuick.Controls 2.5
import Qt.labs.platform 1.1
Form {
    id:root
   
    function connectToServer(){
        if(mainclass.connectToTcp()){
            mainclass.showConnectedInfo()
            return 1
        }else{
            mainclass.showDisConnectedInfo()
            return 0
        }
    }

    mouseArea.onClicked: {
        StackView.push("Hahaform.ui.qml")
    }
}

Upvotes: 0

Views: 722

Answers (2)

bkh6722
bkh6722

Reputation: 173

thanks @Farshid616 for the help. The problem was that my MouseArea wasn't inside the Rectangular. So only I needed is open code and move Mouse Area into Rectangular area, so that the MouseArea would be child of the Rectangular.

Upvotes: 0

Farshid616
Farshid616

Reputation: 1484

You should add this line to your MouseArea to work:

anchors.fill: parent

Upvotes: 1

Related Questions