how two connect two qml file using simple buttom
-
can anybody give a simple program to connect 2 qml files. when a button is clicked in one qml, the other qml file should open, please help,
-
I think you misunderstand the concept behind QML and parent-child hierarchy. But, to answer your query: use Loader element.
-
@sierdzio
i am very new to qml,
can you please explain with a code snippet -
I have do this with an Loader Item.
example:
@ Item {
anchors.fill: parent
width: parent.width
height: parent.heightLoader { id: pageLoader }
}@
When the button is clicked, you emit a signal changePage().
And you can write a slot like this:
@ function getHomePage()
{
pageLoader.source = "home.qml";
}
@
Then you connect the slot and the signal in the main. -
Please wrap your code in '@' tags. And thanks for that snippet, I was too busy to answer myself.
-
[quote author="sierdzio" date="1364280636"]I think you misunderstand the concept behind QML and parent-child hierarchy. But, to answer your query: use Loader element.[/quote]
I am suffering from the same problem (not understanding the concept behind QML and parent-child hierarchy).
Have been searching for hours. Is there a link explaining this topic?
Need to keep all QML pages in memory (for they need to stay connected to C++), so loader will not do the job.
Thanks. -
After the Loader finishes loading the file, it's content (available under item property) works the same as content loaded on application startup, and can be connected with C++ just the same.
Search Qt documentation, it's very helpful in most cases. And for QML - create some example projects. It takes a day or two to get used to the idea (declarative world is different from imperative one, after all), then it's all nice and rosy ;)
-
wspilot, you should create another topic and state your exact issue or goal. Other than that, you ought to have a look at some ready C++&QtQuick examples out there and practice, like sierdzio has already said.
"QDeclarative code samples":http://doc.qt.digia.com/4.7/qdeclarativeexamples.html
"QtQuick 2 code samples":http://qt-project.org/doc/qt-5.0/qtquick/qtquick2-qtquick-codesamples.html
Game example: "5-in-a-row":http://quitcoding.com/?page=work#5inarow
-
Thanks.
Have done that for weeks. Have several Sailfish and plain QML sandboxes set up (but basically for C++/openGL <> QML testing).
I now need to navigate between the QML pages (and keep them in memory). In the normal GUI world very simple: hide, show, popup etc., but I cannot find sth. simular in QML. -
@
visible = false;
@Every Item has this property ;)
-
Aha.
So, I'll create one main.qml with the specific UI pages based on components and use visible as switch.
Thanks.