QML ScrollBar combined with ListView - qt

I'm new to QML and QT so don't blame me if this question is going to sound stupid for most of you but I've search all over the internet without any luck in founding an answer.
What I'm trying to do:
I'm having a ScrollView which has inside of it a ScrollBar and a ListView.
I want that at the moment when I'm scrolling the ListView elements to also move the bar from ScrollBar. In other words, I want to use the ScrollBar as an overall view of your current position, you are not supposed to touch that, its only purpose is for viewing.
My Code:
ScrollView{
implicitHeight: 100
implicitWidth: 50
anchors.fill: parent
ScrollBar.horizontal: ScrollBar{
id: hbar
active: true
policy: ScrollBar.AlwaysOn
anchors {
left: parent.left
top: parent.top
right: parent.right
}
background: Rectangle {
implicitWidth: 100
implicitHeight: 50
opacity: enabled ? 1 : 0.3
color: hbar.down ? "#red" : "black"
}
contentItem: Rectangle {
implicitWidth: 6
implicitHeight: 100
radius: width / 2
color: hbar.pressed ? "#81e889" : "#c2f4c6"
}
}
ListView {
id: listViewParent
height: listViewID.height/10*6
contentHeight: height*2
contentWidth: width*2
clip: false
interactive: false
keyNavigationWraps: true
anchors.right: parent.right
anchors.rightMargin: 0
anchors.left: parent.left
anchors.leftMargin: 0
enabled: true
scale: 1
transformOrigin: Item.Center
anchors.verticalCenter: parent.verticalCenter
boundsBehavior: Flickable.DragAndOvershootBounds
flickableDirection: Flickable.HorizontalFlick
highlightMoveDuration: 0
cacheBuffer: 300
snapMode: ListView.SnapToItem
layoutDirection: Qt.LeftToRight
orientation: ListView.Vertical
model: 1
delegate:
ListView {
width: parent.width;
height: parent.height;
spacing: listViewID.width/8/9
model: MovieListModel {}
orientation: ListView.Horizontal
id: listid
delegate:
Rectangle {
property int recDynamicHeight: listViewID.height/10*6
property int recOriginalHeight: listViewID.height/10*6
property int recDynamiclWidth: listViewID.width/7
property int recOriginalWidth: listViewID.width/7
id: rectPer
width: recDynamiclWidth
height: recDynamicHeight
Image {
id: image1
anchors.fill: parent;
source: model.imgUrl
}
Text {
property bool isVisible: false
color: "#ffffff"
anchors.fill: parent
visible: textid.isVisible
id: textid
text: model.title
font.bold: true
horizontalAlignment: Text.AlignLeft
font.pixelSize: listViewID.width/8/9
topPadding: listViewID.width/8/9
leftPadding: listViewID.width/8/9
}
Text {
anchors.topMargin: listViewID.width/8/9
color: "#ffffff"
anchors.fill: parent
visible: textid.isVisible
id: yearId
text: model.year
horizontalAlignment: Text.AlignLeft
font.pixelSize: listViewID.width/8/9
topPadding: listViewID.width/8/9*2
leftPadding: listViewID.width/8/9
}
MouseArea {
anchors.fill: parent
onPressed: {
rectPer.recDynamicHeight = rectPer.recOriginalHeight;
rectPer.recDynamicHeight += rectPer.recOriginalHeight/10;
rectPer.recDynamiclWidth += rectPer.recOriginalWidth/10;
console.log(textid.isVisible);
textid.isVisible = true;
textid.visible = textid.isVisible;
console.log(sideButtonID.x);
console.log(sideButtonID.y);
console.log(model.year + " clicked");
}
onClicked: {
console.log("INDEX: " + model.id)
load_page(PageType.movie_detailed_view, model.title, model.description, model.imgUrl, model.type, model.year)
}
onReleased: {
rectPer.recDynamicHeight = rectPer.recOriginalHeight;
rectPer.recDynamiclWidth = rectPer.recOriginalWidth;
textid.isVisible = false;
textid.visible = textid.isVisible;
}
}
}
}
}
}
Layout:

You could try use a Flickable instead of a ScrollView and spawn a ListView there(delegates: Rectangles). Then, spawn the Scrollbar inside the ListView

Related

Best way to add space around a ColumnLayout?

I like that there is a spacing property to add space between items in a layout. But is it also possible to add space around a layout?
See my code below. I try to use anchors.margins on the ColumnLayout but that does not work.
Rectangle {
id: leftSelectionRect
anchors.top: parent.top
anchors.right: leftLine.left
implicitWidth: leftSelectionLayout.implicitWidth
implicitHeight: leftSelectionLayout.implicitHeight
color: CustomProperties.Colors.transparentSelectionBackground
ColumnLayout {
id: leftSelectionLayout
spacing: CustomProperties.Margins.small
anchors.margins: CustomProperties.Margins.small // This is what I would like to do, but it does not work.
CustomComponents.HeaderText {
id: leftText
text: Converter.formatDuration(ui.selectionModel.startUs, Converter.MicroSeconds, Converter.MicroSeconds)
}
CustomComponents.HeaderText {
id: leftdeltaText
text: "Δ " + Converter.formatDuration(ui.selectionModel.deltaUs, Converter.MicroSeconds, Converter.MicroSeconds)
}
}
}
EDIT
The following is the first attempt I have made that works, but it is messy. There must be a better way:
Rectangle {
id: leftSelectionRect
anchors.top: parent.top
anchors.right: leftLine.left
implicitWidth: leftSelectionLayout.implicitWidth + CustomProperties.Margins.medium * 2
implicitHeight: leftSelectionLayout.implicitHeight + CustomProperties.Margins.small * 2
color: CustomProperties.Colors.transparentSelectionBackground
ColumnLayout {
id: leftSelectionLayout
spacing: CustomProperties.Margins.small
anchors.topMargin: CustomProperties.Margins.small
anchors.bottomMargin: CustomProperties.Margins.small
anchors.leftMargin: CustomProperties.Margins.medium
anchors.rightMargin: CustomProperties.Margins.medium
anchors.fill: parent
CustomComponents.HeaderText {
id: leftText
text: Converter.formatDuration(ui.selectionModel.startUs, Converter.MicroSeconds, Converter.MicroSeconds)
}
CustomComponents.HeaderText {
id: leftdeltaText
text: "Δ " + Converter.formatDuration(ui.selectionModel.deltaUs, Converter.MicroSeconds, Converter.MicroSeconds)
}
}
}
Do not add anchors.fill:parent to your inner ColumnLayout but to your outer wrapper component:
Item {
anchors.fill: parent
anchors.margins: 10
ColumnLayout {
id: layout
width: parent.width
spacing: 10
Rectangle {
color: "red"
Layout.preferredHeight: 100
Layout.preferredWidth: parent.width
}
Rectangle {
color: "blue"
Layout.preferredHeight: 100
Layout.preferredWidth: parent.width
}
Rectangle {
color: "green"
Layout.preferredHeight: 100
Layout.preferredWidth: parent.width
}
}
}
At all you should avoid setting height property or anchors.top AND anchors.bottom properties to your ColumnLayout because it calculates its height at its own.

Long TabBar - adding a size and position indicator to reflect the presence of off-screen tabs

I have a tab bar with a stacklayout like the following:
Rectangle {
id: rect
height: 190
anchors.right: parent.right
anchors.left: parent.left
color: "transparent"
anchors.top: uniqueHandleText.bottom
anchors.topMargin: 100
TabBar {
id: frame
anchors.right: parent.right
anchors.left: parent.left
background: Rectangle {
color: "#737373"
}
x: -hbar.position * width
Repeater {
model: wizard.categories
TabButton {
id: tabData
property bool selected: false
text: modelData.name
width: 200
font.pixelSize: 18
contentItem: Text {
text: tabData.text
font: tabData.font
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter
elide: Text.ElideRight
wrapMode: Text.WordWrap
color: "#FFFFFF"
}
background: Rectangle {
implicitWidth: frame.width
implicitHeight: 180
opacity: enabled ? 1 : 0.3
color: tabData.checked ? "#BD9CBE": "#737373"
}
}
}
}
ScrollBar {
id: hbar
hoverEnabled: true
active: hovered || pressed
orientation: Qt.Horizontal
size: rect.width / frame.width
anchors.left: parent.left
anchors.right: parent.right
anchors.top: frame.bottom
}
Text {
font.pixelSize: 18
text: "Next"
anchors.right: parent.right
visible: frame.x != frame.width ? true: false
}
StackLayout {
id: stack1
anchors.left: parent.left
anchors.right: parent.right
anchors.top: frame.bottom
currentIndex: frame.currentIndex
Repeater {
model: wizard.categories
Item {
id: homeTab
TabBar {
id: homeTabTab
anchors.right: parent.right
anchors.left: parent.left
anchors.top: parent.top
height: 180
background: Rectangle {
color: "#958096"
}
Repeater {
model: modelData.sub_categories
TabButton {
property bool selected: false
id: currentTab
text: modelData.name
width: 200
font.pixelSize: 18
background: Rectangle {
implicitWidth: frame.width
implicitHeight: 180
opacity: enabled ? 1 : 0.3
color: currentTab.checked ? "#958096": "#8D758E"
}
contentItem: Text {
text: currentTab.text
font: currentTab.font
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter
elide: Text.ElideRight
wrapMode: Text.WordWrap
color: "#FFFFFF"
MouseArea {
anchors.fill: parent
onClicked: {
if(currentTab.checked){
currentTab.checked = false
} else {
currentTab.checked = true
}
}
onDoubleClicked: {
currentTab.selected = true
var found = false;
var someText = frame.itemAt(stack1.currentIndex).text;
print(someText)
for(var i = 0; i<wizard.selectedSkills.count; i++){
if(wizard.selectedSkills.get(i).name === someText){
wizard.selectedSkills.get(i).sub_categories.append({"name":currentTab.text});
wizard.skills.push({"name": someText})
found = true;
}
}
if(!found){
print(currentTab.text)
wizard.selectedSkills.append({"name":someText, "sub_categories":[{"name":currentTab.text}]})
}
print(window.selectedSkills)
}
}
}
}
}
}
}
}
}
}
I've tried many different things to add a scrollbar or to figure out how to use the flickable functionality that TabBar has. However, the documentation doesn't specify how it works, it just does. Therefore, they are not accessible (or even rewritteable, to use those properties). I want to add a small indicator like an arrow to specify that there is more elements for ease of navigation on desktop on top of the TabBar functionality.
It doesn't seem like the necessary properties are exposed in order to make this happen the easy way.
However, since this is QML, it means the whole object tree is gaping wide open to introspection, allowing us to establish that the item that does the flicking is the contentItem of a ListView inside the Container the ToolBar inherits. The view happens to be the second visible child, although this is technically "private implementation" that one should not rely on. So it is better to take some extra care to establish whether or not you have the correct object.
ApplicationWindow {
id: main
width: 640
height: 480
visible: true
TabBar {
id: toolbar
width: parent.width
height: 50
Repeater {
model: 10
TabButton {
text: "test " + index
width: 100
}
}
}
Rectangle {
height: 5
width: main.width * (view ? view.visibleArea.widthRatio : toolbar.width / toolbar.contentWidth)
color: "red"
anchors.top: toolbar.bottom
x: view ? (main.width - width) * (view.contentX / (view.contentWidth - view.width)) : 0
}
property ListView view: {
var l = toolbar.visibleChildren.length
while (--l) if ("cacheBuffer" in toolbar.visibleChildren[l]) return toolbar.visibleChildren[l]
return null
}
}
And there you have it. We iterate the tabview children until we find one that has a property cacheBuffer which is fairly unique to ListView, and once we have that, we can access the needed properties. As you see, for the indicator width we can do even without the list view, as the toolbar exposes a contentWidth property, but for the indicator position there is no workaround.
And it works:

qt qml how can I create a list view feed item containing an icon and description?

I created an example. I do not know why I get a crash when I try to resize the window horizontally. Crash happens only when iconVisible is true
here is the qml code from the main, paste this in a hello world qt quick controls 2 project to test:
import QtQuick 2.7
import QtQuick.Controls 2.0
import QtQuick.Layouts 1.0
import QtQuick.XmlListModel 2.0
ApplicationWindow {
visible: true
width: 640
height: 480
title: qsTr("Hello World")
Page {
anchors.fill: parent
XmlListModel{
id : modelId
namespaceDeclarations: "declare namespace media = 'http://search.yahoo.com/mrss/';"
source: "http://api.flickr.com/services/feeds/photos_public.gne?format=rss2&tags="
query: "//item[title and media:thumbnail and media:content]"
}
ListView {
anchors.fill: parent
model: modelId
Layout.fillWidth: true
delegate: itemDelegateId
ScrollBar.vertical: ScrollBar {}
}
Component {
id: itemDelegateId
Rectangle {
property bool iconVisible: true
property string contentText: "contentaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
property double itemHeight: 100
property int titleTextSize: 32
property int columnLayoutLeftMargin: (iconVisible)? 20 : 0
property string borderColor: "black"
property int iconSize: (iconVisible)? 40 : 0
height : itemHeight
anchors {
left: parent.left
right: parent.right
}
border.color: borderColor
border.width: 1
RowLayout {
anchors {
fill: parent
}
Rectangle {
id: notificationIconId
visible: iconVisible
anchors {
top: parent.top
}
height: iconSize
width: iconSize
Image {
anchors.fill: parent
fillMode: Image.PreserveAspectFit
}
}
ColumnLayout {
id: columnLayoutId
anchors {
top: parent.top
bottom: parent.bottom
left: notificationIconId.right
right: parent.right
}
Text {
id: contentId
anchors {
top: parent.top
bottom: parent.bottom
}
Layout.fillWidth: true
font.pixelSize: 20
elide: Text.ElideRight
maximumLineCount: 3
wrapMode: Text.WrapAtWordBoundaryOrAnywhere
color: "black"
text: contentText
}
}
}
}
}
}
}
There are a few issues here. The first is that Layout.fillWidth: true has no effect, as Page is not a layout:
ListView {
anchors.fill: parent
model: modelId
Layout.fillWidth: true // remove
delegate: itemDelegateId
ScrollBar.vertical: ScrollBar {}
}
The second is that you shouldn't specify width and height for items in a layout:
Rectangle {
id: notificationIconId
visible: iconVisible
anchors {
top: parent.top
}
height: iconSize // Should be Layout.preferredHeight: iconSize
width: iconSize // Should be Layout.preferredWidth: iconSize
Image {
anchors.fill: parent
fillMode: Image.PreserveAspectFit
}
}
You can't use horizontal anchors on an item managed by a horizontal layout:
ColumnLayout {
id: columnLayoutId
anchors {
top: parent.top
bottom: parent.bottom
// This ColumnLayout is managed by a RowLayout, so these two lines have to go
left: notificationIconId.right
right: parent.right
}
}
Same thing for the Text item:
Text {
id: contentId
// Can't use vertical anchors on an item that is managed by a ColumnLayout
anchors {
top: parent.top
bottom: parent.bottom
}
Layout.fillWidth: true
font.pixelSize: 20
elide: Text.ElideRight
maximumLineCount: 3
wrapMode: Text.WrapAtWordBoundaryOrAnywhere
color: "black"
text: contentText
}
With all of those issues fixed, it seems to work as expected:
import QtQuick 2.7
import QtQuick.Controls 2.0
import QtQuick.Layouts 1.0
import QtQuick.XmlListModel 2.0
ApplicationWindow {
visible: true
width: 640
height: 480
title: qsTr("Hello World")
Page {
anchors.fill: parent
XmlListModel{
id : modelId
namespaceDeclarations: "declare namespace media = 'http://search.yahoo.com/mrss/';"
source: "http://api.flickr.com/services/feeds/photos_public.gne?format=rss2&tags="
query: "//item[title and media:thumbnail and media:content]"
}
ListView {
anchors.fill: parent
model: modelId
delegate: itemDelegateId
ScrollBar.vertical: ScrollBar {}
}
Component {
id: itemDelegateId
Rectangle {
property bool iconVisible: true
property string contentText: "contentaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
property double itemHeight: 100
property int titleTextSize: 32
property int columnLayoutLeftMargin: (iconVisible)? 20 : 0
property string borderColor: "black"
property int iconSize: (iconVisible)? 40 : 0
height : itemHeight
anchors {
left: parent.left
right: parent.right
}
border.color: borderColor
border.width: 1
RowLayout {
anchors {
fill: parent
}
Rectangle {
id: notificationIconId
visible: iconVisible
anchors {
top: parent.top
}
Layout.preferredHeight: iconSize
Layout.preferredWidth: iconSize
Image {
anchors.fill: parent
fillMode: Image.PreserveAspectFit
}
}
ColumnLayout {
id: columnLayoutId
anchors {
top: parent.top
bottom: parent.bottom
}
Text {
id: contentId
Layout.fillWidth: true
font.pixelSize: 20
elide: Text.ElideRight
maximumLineCount: 3
wrapMode: Text.WrapAtWordBoundaryOrAnywhere
color: "black"
text: contentText
}
}
}
}
}
}
}

How to animate a message that appears on bottom?

I'm showing a message on the bottom:
Msg.qml
import QtQuick 2.4
Item {
property alias text: mf.text
anchors.fill: parent
antialiasing: false
opacity: 0.9
z: 100
MsgForm {
id: mf
width: parent.width
y: parent.height - height - 5
}
}
MsgForm.ui.qml
import QtQuick 2.4
Item {
property alias text: msg.text
width: 200
id: message
height: msg.height+10
Rectangle {
id: rectangle
color: "#fb9191"
anchors.fill: parent
border.color: "#fd6666"
border.width: 2
Text {
id: msg
anchors.top: parent.top
anchors.topMargin: 2
textFormat: Text.PlainText
anchors.right: parent.right
anchors.rightMargin: 4
anchors.left: parent.left
anchors.leftMargin: 4
wrapMode: Text.WordWrap
clip: false
font.bold: true
font.pointSize: 12
font.family: "Tahoma"
}
}
}
How can I animate the form to appear from the bottom smoothly?
After the animation, if the window resizes, the message must stay always on the bottom.
You can play with anchors.bottomMargin property to raise the message item from the bottom.
import QtQuick 2.4
Item {
property alias text: mf.text
anchors.fill: parent
antialiasing: false
opacity: 0.9
z: 100
MsgForm {
id: mf
property bool showing: false
width: parent.width
anchors{
bottom: parent.bottom
bottomMargin: mf.showing ? 0 : -mf.height
Behavior on bottomMargin{
NumberAnimation{ }
}
}
}
}
Thanks everyone. In the end I've solved the issue by following advices received in the qtcentre forum.
The desired effect can be achieved easily by defining a local numerical property that is use to bind to either an anchors.XXXXmargin or the y property expression.
Following this approach a possible solution is the following:
MsgForm {
property bool showing: false
property int position: showing ? height : 0
width: parent.width
y: parent.height - position
Behavior on position {
NumberAnimation {duration: 500}
}
}
You can make an animation on the opacity change:
Msg.qml
import QtQuick 2.4
Item {
property alias text: mf.text
anchors.fill: parent
antialiasing: false
opacity: 0.9
z: 100
MouseArea{
anchors.fill: parent
onClicked: mf.opacity = !mf.opacity
}
MsgForm {
id: mf
//y: parent.height - height - 5
opacity:0
Behavior on opacity {
NumberAnimation{
duration:600
}
}
width: parent.width
anchors.bottom: parent.bottom
}
}
or any other NumberAnimation. I recommand you to create States, within it do some propertyChanges, and on some actions, example button clicked change states.
example in your MsgForm.ui.qml add:
MouseArea{
anchors.fill: parent
onClicked: mf.state= "show"
}
and in the action, example:
in my mouseArea I change the state of mf
MouseArea{
anchors.fill: parent
onClicked: mf.state= "show"
}
If you want an Animation on the y try this:
MsgForm.ui.qml
import QtQuick 2.4
Item {
id: message
property alias text: msg.text
width: parent.width
height: msg.height+10
Rectangle {
id: rectangle
color: "#fb9191"
anchors.fill: parent
border.color: "#fd6666"
border.width: 2
Text {
id: msg
anchors.top: parent.top
anchors.topMargin: 2
textFormat: Text.PlainText
anchors.right: parent.right
anchors.rightMargin: 4
anchors.left: parent.left
anchors.leftMargin: 4
wrapMode: Text.WordWrap
clip: false
font.bold: true
font.pointSize: 12
font.family: "Tahoma"
}
}
Behavior on y {
NumberAnimation{
duration:300
}
}
states: [
State {
name: "show"
PropertyChanges {
target: message
y: parent.height - height
}
},
State {
name: "hide"
PropertyChanges {
target: message
y: parent.height + height + 5
}
}
]
}
Msg.qml
import QtQuick 2.4
Rectangle {
property alias text: mf.text
width:800
height: 480
antialiasing: false
opacity: 0.9
z: 100
MouseArea{
anchors.fill: parent
onClicked: mf.state= "show"
}
MsgForm {
id: mf
//y: parent.height - height - 5
y: parent.height +height + 5
width: parent.width
}
}

QML ListView won't respond on mouse click

Hi all I have tried several things but I can't make my ListView to response to mouse click.
Here is my code of ListView:
ListView {
id: listview1
x: 0
y: 82
// width: 574
// height: 967
width: window.width
height: window.height
visible: true
keyNavigationWraps: false
boundsBehavior: Flickable.DragAndOvershootBounds
opacity: 1
maximumFlickVelocity: 2500
anchors.leftMargin: 0
highlightMoveSpeed: 489
contentWidth: 0
preferredHighlightEnd: 2
spacing: 5
highlightRangeMode: ListView.NoHighlightRange
snapMode: ListView.SnapToItem
anchors.bottomMargin: 0
anchors.rightMargin: 0
anchors.topMargin: 82
anchors.fill: parent
model: myModel
delegate:Component {
//id: contactDelegate
Item {
property variant myData: model
width: 574; height: 90
Column {
x: 12
y: 0
width: 562
height: 90
anchors.rightMargin: 0
anchors.bottomMargin: 0
anchors.leftMargin: 12
anchors.topMargin: 0
anchors.fill: parent
spacing: 2
Text { text: '<b>ID: </b> ' + id_korisnika ; verticalAlignment: Text.AlignTop; wrapMode: Text.NoWrap; horizontalAlignment: Text.AlignHCenter; color:"steelblue"; font.family: "Helvetica"; font.pointSize: 10 }
Text { text: '<b>Ime: </b> ' + ime_korisnika ; horizontalAlignment: Text.AlignHCenter; color:"steelblue"; font.family: "Helvetica"; font.pointSize: 10 }
Text { text: '<b>Prezime: </b> ' + prezime_korisnika; horizontalAlignment: Text.AlignHCenter; color:"steelblue"; font.family: "Helvetica"; font.pointSize: 10 }
Text { height: 16; text: '<b>Broj telefona: </b> ' + broj_korisnika ; verticalAlignment: Text.AlignVCenter; horizontalAlignment: Text.AlignHCenter; color:"steelblue"; font.family: "Helvetica"; font.pointSize: 10 }
Text { text: '<b>Adresa: </b> ' + adresa_korisnika ; horizontalAlignment: Text.AlignHCenter; color:"steelblue"; font.family: "Helvetica"; font.pointSize: 10 }
MouseArea {
id: mouse_area1
z: 1
hoverEnabled: false
anchors.fill: parent
}
}
}
}
//delegate: contactDelegate
highlight: Rectangle {color:"black"; radius: 5; opacity: 0.7
}
focus: true
}
I have tried to put my code in all areeas but I can't make it work. any suggestion is nice.
See KeyInterction sample from QtCreator. There is your answer :)
You can see sample delegate as follow:
ListViewDelegate:
Item {
id: container
width: ListView.view.width; height: 60; anchors.leftMargin: 10; anchors.rightMargin: 10
Rectangle {
id: content
anchors.centerIn: parent; width: container.width - 40; height: container.height - 10
color: "transparent"
antialiasing: true
radius: 10
Rectangle { anchors.fill: parent; anchors.margins: 3; color: "#91AA9D"; antialiasing: true; radius: 8 }
}
Text {
id: label
anchors.centerIn: content
text: "List element " + (index + 1)
color: "#193441"
font.pixelSize: 14
}
MouseArea {
id: mouseArea
anchors.fill: parent
hoverEnabled: true
onClicked: {
container.ListView.view.currentIndex = index
container.forceActiveFocus()
}
}
}
The key is MouseArea section.
Good luck - S.M.Mousavi
i dont see onClicked handler code in your MouseArea (mouse_area1). How are you trying to capture/respond the mouse click.
Try following code and see what happens.
MouseArea {
id: mouse_area1
z: 1
hoverEnabled: false
anchors.fill: parent
onClicked:{
console.log("test");
}
}

Resources