import QtQuick 2.12 import QtQuick.Window 2.12 import QtQuick.Controls 2.12 Window { visible: true width: 640 height: 480 TextField { id: searchField placeholderText: "Search..." } RoundButton { id: clearSearch anchors.right: searchField.right anchors.top: searchField.top anchors.bottom: searchField.bottom anchors.margins: 5 text: "X" opacity: 0.5 onClicked: { console.log("clear btn clicked"); searchField.clear(); searchField.forceActiveFocus(); } } }