Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. How can I use Layouts in ' Qt Quick ' ?
Forum Updated to NodeBB v4.3 + New Features

How can I use Layouts in ' Qt Quick ' ?

Scheduled Pinned Locked Moved QML and Qt Quick
3 Posts 2 Posters 908 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Y Offline
    Y Offline
    ysing
    wrote on last edited by
    #1

    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.0

    Rectangle {
    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.

    1 Reply Last reply
    0
    • JKSHJ Offline
      JKSHJ Offline
      JKSH
      Moderators
      wrote on last edited by
      #2

      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

      Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

      1 Reply Last reply
      0
      • Y Offline
        Y Offline
        ysing
        wrote on last edited by
        #3

        Thanks JKSH I used Qt Quick Layouts and the QML Button.

        Actually the QML Button is much more easier tan creating my own button .

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved