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. Not Able to align the rectangles

Not Able to align the rectangles

Scheduled Pinned Locked Moved QML and Qt Quick
2 Posts 2 Posters 718 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.
  • R Offline
    R Offline
    raghaw
    wrote on last edited by
    #1

    Hi All,

    I have one problem in vertically aligning the rectangles.

    @import QtQuick 2.0
    import "qrc:/gui"

    Rectangle {
    id: main_screen
    width: 480
    height: 700
    color: "black"

    Rectangle {
        id: top_screen
        anchors.centerIn:  top_screen.horizontalCenter
    
        ToggleButton {
            id: settings_button
            source: "qrc:/icons/cavitron_logo.png"
            x: 180
            property int state: 0
            property string prevScreen: ""
    
            onButtonLongPressed: {
                if (state == 0) {
                    prevScreen = loader.source
                    loader.source = "qrc:/gui/SettingsScreen.qml"
                    state = 1
                }
                else if (state == 1) {
                    loader.source = prevScreen
                    state = 0
                }
            }
        }
    }
    
    Rectangle {
        id: middle_screen
        anchors.top: top_screen.bottom
        anchors.centerIn: parent
    
        Loader {
            id: loader
            anchors.centerIn: middle_screen
            source: "qrc:/gui/ScaleScreen.qml"
        }
    
        Connections {
            target: loader.item
            onShowScreen: loader.source = link
        }
    }
    
    Rectangle {
        id: lock_screen // bottom screen
        anchors.top: middle_screen.bottom
    
        Image {
            source: "qrc:/icons/lock.png"
        }
    }
    

    }
    @

    this last rectangle is always coming in the middle of the middle of the screen on left side and not coming in bottom as intended.Can anybody help me in solving this issue.?

    Thanks

    1 Reply Last reply
    0
    • p3c0P Offline
      p3c0P Offline
      p3c0
      Moderators
      wrote on last edited by
      #2

      Hi,

      Try anchoring it to bottom of your main_screen.
      @
      anchors.bottom: main_screen.bottom
      @

      157

      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