Why there is no button to add a empty slot?
-
I follow the example to get start of programming. But why I cannot find the button to add empty slot in the State Pane.
I mean, there is no such a button there to add State. Where can I find it? -
Your answer is not very informative, could you provide some screenshots of the problem. Also this might be the problem with Qt Designer not understanding your qml code. Try creating an empty project, and see if the problem remains. Also this might happen because of a new QtQuick version, so I might suggest trying Importing an older version like 2.2 or 2.0.
P.S. You might also add states manualy via qml code, like this:
...
@
states: [
State {
name: "State1"PropertyChanges { target: sometarget x: somthing.x y: somthing.y } }, State { name: "State2" PropertyChanges { target: sometarget x: somthingelse.x y: somthingelse.y } } ]@
P.P.S. Try not to ask the same question twice, rater edit one question.
-
!http://qt-project.org/doc/qtcreator-2.8/images/qmldesigner-tutorial-desing-mode.png(There is a button on the top right, with a Plus Sign)!
-
So it seems you don't have one? Well try my suggestion and see if they work. Also Qt Designer IMHO, is more of a helping tool, rather than an actual development device, so I suggest that you also familiarise with the actual qml coding (it's not that hard, trust me), and don't rely on designer, as it has a tendency to break every now and then when coding gets serious and complex.
-
As you can see, there is a button with a Plus Sign on the top, you can click it to add empty slots. But in my project, why I cannot find it?
And...I am just a novice to start using Qt 5. Maybe its a simple problem for you...
-
[quote author="JasonLee" date="1413830002"]As you can see, there is a button with a Plus Sign on the top, you can click it to add empty slots. But in my project, why I cannot find it?
And...I am just a novice to start using Qt 5. Maybe its a simple problem for you...[/quote]
Trust me we've all been there, and Qt always suprises all of us (plesantly or else). If you didn't understand my solution, I may guide you through it but it would be easier if you showed me your main.qml code. -
When I start some examples in the Welcome Panel in Qt 5, there are actually this kind of buttons in the State Pane on the top of the Qt Designer in these examples. Yet when I begin a new project, there is nothing there.
-
@import QtQuick 2.3
import QtQuick.Controls 1.2ApplicationWindow {
id: page
visible: true
width: 640
height: 480
color: "#343434"
title: qsTr("Program_MyChild")menuBar: MenuBar { Menu { title: qsTr("File") MenuItem { text: qsTr("&Open") onTriggered: console.log("Open action triggered"); } MenuItem { text: qsTr("Exit") onTriggered: Qt.quit(); } } } Rectangle { id: topLeftRect x: 10 width: 200 height: 200 color: "#00000000" radius: 6 anchors.left: parent.left anchors.leftMargin: 10 anchors.top: parent.top anchors.topMargin: 20 border.color: "#808080" border.width: 1 MouseArea { id: mouseArea1 onClicked: page.state = '' } } Rectangle { id: middleRightRect x: 8 y: 2 width: 200 height: 200 color: "#00000000" radius: 6 anchors.verticalCenter: parent.verticalCenter anchors.right: parent.right anchors.rightMargin: 10 MouseArea { id: mouseArea2 anchors.fill: parent onClicked: page.state = 'State1' } border.width: 1 border.color: "#808080" } Rectangle { id: bottomLeftRect y: 264 width: 200 height: 200 color: "#00000000" radius: 6 anchors.left: parent.left anchors.leftMargin: 10 anchors.bottom: parent.bottom anchors.bottomMargin: 20 MouseArea { id: mouseArea3 anchors.fill: parent onClicked: page.state = 'State2' } border.width: 1 border.color: "#808080" } Image { id: image1 x: 10 y: 20 width: 200 height: 200 source: "child.jpg" }
}
@ -
Oh, yes. I think I solved it.
Don't laugh at me... I just find that you should add codes in main.qml first, and that button will automatically show up...
-
I think I found the source of the problem, -Qt Designer can't add states to an ApplicationWindow root object, so a quick dirty workaround would bу to firstly work with a root Rectangle object, add states and then turn it into an ApplicatonWindow.-
Sorry, my bad, ApplicationWindow does not seem to have states at all. So work with a child rectangle if you realy need states and ApplicationWindow neats at the same time/ -
Yes, thank you very much!
I think you are right, I should not use ApplicationWindow. Just use Rectangle straightly, that will work correctly.