Invisible buttons are still functioning
-
@vishnu Here's an example to pop off an item of any depth. This link clearly explains.
Here's an example I prepared://Adds 10 items into StackView and also pops to an item at index 4 import QtQuick 2.4 import QtQuick.Controls 1.3 Rectangle { width: 200 height: 100 StackView { id: stack anchors.fill: parent } Component { id: item Text { } } Row { anchors.bottom: parent.bottom Button { text: "Add" onClicked: { for(var a=0; a<10; a++) { var comp = item stack.push(comp.createObject(stack,{"text": "Item"+a})); } } } Button { text: "Pop" onClicked: { var current = stack.get(4) stack.pop(current) } } } }
You will also need to set
destroyOnPop
totrue
as documented here to not allow items destroy on pop. -
@p3c0
sorry for late reply. As you said I modified my program from visible concept to StackView. But now the status of the buttons (on/off) is not preserved.Because when i am pushing I am not makingdestroyOnPop
to false. How to do that with this syntax.Button{ id:openDetailedview text:"Detailed View" onClicked: { stackView.push(Qt.resolvedUrl("DetailedView.qml")) } }
In DetailedView.qml there are many on/off buttons.
Also, It says thatqml: Warning: StackView: cannot transition an item that is anchored!
.May i know when do we get this kind of error because i even setanchors.fill:parent
. Thanks. -
How to do that with this syntax.
stackView.push( { item: Qt.resolvedUrl("DetailedView.qml"), destroyOnPop:false } );
Also, It says that qml: Warning: StackView: cannot transition an item that is anchored!.May i know when do we get this kind of error because i even set anchors.fill:parent
That is the problem. Don't do it.
-
@p3c0
stackView.push( { item: Qt.resolvedUrl("DetailedView.qml"), destroyOnPop:false } );
I did like this but still status it not restored. So what i did is instantiate the component and make is invisible.
MainView.qmlButton{ id:openDetailedview text:"Detailed View" onClicked: { stackView.push({item:detailedView,destroyOnPop:false}) } } DetailedView{ id:detailedView visible: false }
works perfect like this but still
qml: Warning: StackView: cannot transition an item that is anchored!
is not solved what should i do?
I even tried replacing
anchors.fill:parent
with
width: parent.width
height: parent.height
anchors.left: parent.left
but no use. -
@p3c0
Sorry.Now i removed it but still. the warning is not shown when pushing deatiledView.qml. But inside deatiledView. I have different buttons.upon clicking i am pushing another qml files.here is the problem.In my case when I am pushing the AcyclicRegister.qml I am getting the error
DetailedView.qmlItem { id:centralView // width: parent.width // height: parent.height ControlView{ id:controlview height: (centralView.height) width: centralView.width/2 anchors.left: centralView.left anchors.leftMargin: festodesign.buttonGap Connections{ onAcyclicButtonClicked: { stackView.push({item:acyclicRegister,destroyOnPop:false}) } } AcyclicRegister{ id:acyclicRegister visible: false property int byteIndex: 1 onRegisterstatus: { tcpCommunicationPort.datafromQml(byteIndex,index,data);//sending to cpp } } DisplayView{ id: displayView height: (centralView.height) width: centralView.width/2 anchors.left: controlview.right anchors.leftMargin: festodesign.buttonGap anchors.top: parent.top Connections{ onAcyclicButtonClicked: {stackView.push({item:sAcyclicRegister,destroyOnPop:false})} } SAcyclicRegister{ id:sAcyclicRegister visible: false property int byteIndex: 1 onRegisterstatus: { // tcpCommunicationPort.datafromQml(byteIndex,index,-1);//sending to cpp } }
AcyclicRegister.qml
Register{ id:acyclicRegister //not showing inside text elements }
Register.qml
Rectangle { id: register //not showing inside text elements }
-
@p3c0
Ooops.I missed it. Thanks a lot ! works perfect :).
I have a right-arrow button on my footer where i am pushing a qml file upon clicking. when it is loaded how to disable this button on the footer? Also, I don't want to push the same qml file again and again.How can make a check before pushing If that is alread in the stack i don't the push it? I tried like getting the current item but i always get stacknull.
var comp=stackView.get(Stack.index);
console.log("latest stack"+comp)
-
I have a right-arrow button on my footer where i am pushing a qml file upon clicking. when it is loaded how to disable this button on the footer?
enabled = false
on clickHow can make a check before pushing If that is alread in the stack i don't the push it?
2 ways.
var myItem = stackView.push( { item: Qt.resolvedUrl("DetailedView.qml"), destroyOnPop:false } ); //check myItem and store it somewhere if(myItem) { }
var myItem = stackView.push( { item: Qt.resolvedUrl("DetailedView.qml"), destroyOnPop:false } ); var comp=stackView.get(myItem.Stack.index); //need the item to get its index and not just Stack.index