How can I use Layouts in ' Qt Quick ' ?
-
Hello,
I want t use Qt/c++ layouts with my personalized widget (that I've created using ' Qt quick ') but I didn't know how to realize this(in my case I want insert a picture and a button at the center of the home page).
here is the ' main.cpp ':
@#include <QGuiApplication>
#include <QQuickView>int main(int argc, char** argv)
{
QGuiApplication app(argc, argv);
QQuickView view;view.resize(800, 480); view.setResizeMode(QQuickView::SizeRootObjectToView); view.setSource(QUrl("qrc:///main.qml")); view.show(); return app.exec();
}
@main.qml
@
import QtQuick 2.0Rectangle {
color: "#ffffff"}
@button.qml
@import QtQuick 2.0
Rectangle {
width: 200
height: 50
radius: 14
border.width: 6
border.color: "#e67739"
gradient: Gradient {
GradientStop {
position: 0
color: "#e8d84a"
}GradientStop { position: 1 color: "#ffffff" } GradientStop { position: 0.391 color: "#eade70" } } Text { anchors.centerIn: parent text: "Enter" } }
@
Thanks in advance.
-
Hi,
See "Qt Quick Layouts":http://qt-project.org/doc/qt-5/qtquicklayouts-index.html
By the way,instead of creating your own button, you can use the official "QML Button":http://qt-project.org/doc/qt-5/qml-qtquick-controls-button.html and change its looks using "ButtonStyle":http://qt-project.org/doc/qt-5/qml-qtquick-controls-styles-buttonstyle.html