Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Rectangle not conformed at window

Rectangle not conformed at window

Scheduled Pinned Locked Moved Solved General and Desktop
3 Posts 2 Posters 472 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.
  • Nio74N Offline
    Nio74N Offline
    Nio74
    wrote on last edited by
    #1

    Hello,why is the rectangle not as wide as the window?

    0_1549890999195_Cattura.PNG

    This is main.qml

    ApplicationWindow {
        id: window
        visible: true
        width: 640
        height: 480
        title: qsTr("Stack")
    
        header: ToolBar {
            contentHeight: toolButton.implicitHeight
    
            ToolButton {
                id: toolButton
                text: stackView.depth > 1 ? "\u25C0" : "\u2630"
                font.pixelSize: Qt.application.font.pixelSize * 1.6
                onClicked: {
                    if (stackView.depth > 1) {
                        stackView.pop()
                    } else {
                        drawer.open()
                    }
                }
            }
    
            Label {
                text: stackView.currentItem.title
                anchors.centerIn: parent
            }
        }
    
        Drawer {
            id: drawer
            width: window.width * 0.66
            height: window.height
    
            Column {
                anchors.fill: parent
    
                ItemDelegate {
                    text: qsTr("Page 1")
                    width: parent.width
                    onClicked: {
                        stackView.push("Page1Form.ui.qml")
                        drawer.close()
                    }
                }
                ItemDelegate {
                    text: qsTr("Page 2")
                    width: parent.width
                    onClicked: {
                        stackView.push("Page2Form.ui.qml")
                        drawer.close()
                    }
                }
            }
        }
    
        StackView {
            id: stackView
            initialItem: "HomeForm.ui.qml"
            anchors.fill: parent
        }
    

    this is my first page

    Page {
        id:mainPge
        width: 600
        height: 400
    
        title: qsTr("Home")
    
        Rectangle {
            id: rectangle
            //anchors.fill: parent
            width: mainPge.width
            height: 200
            color: "#ffffff"
        }
    }```
    J.HilkJ 1 Reply Last reply
    0
    • Nio74N Nio74

      Hello,why is the rectangle not as wide as the window?

      0_1549890999195_Cattura.PNG

      This is main.qml

      ApplicationWindow {
          id: window
          visible: true
          width: 640
          height: 480
          title: qsTr("Stack")
      
          header: ToolBar {
              contentHeight: toolButton.implicitHeight
      
              ToolButton {
                  id: toolButton
                  text: stackView.depth > 1 ? "\u25C0" : "\u2630"
                  font.pixelSize: Qt.application.font.pixelSize * 1.6
                  onClicked: {
                      if (stackView.depth > 1) {
                          stackView.pop()
                      } else {
                          drawer.open()
                      }
                  }
              }
      
              Label {
                  text: stackView.currentItem.title
                  anchors.centerIn: parent
              }
          }
      
          Drawer {
              id: drawer
              width: window.width * 0.66
              height: window.height
      
              Column {
                  anchors.fill: parent
      
                  ItemDelegate {
                      text: qsTr("Page 1")
                      width: parent.width
                      onClicked: {
                          stackView.push("Page1Form.ui.qml")
                          drawer.close()
                      }
                  }
                  ItemDelegate {
                      text: qsTr("Page 2")
                      width: parent.width
                      onClicked: {
                          stackView.push("Page2Form.ui.qml")
                          drawer.close()
                      }
                  }
              }
          }
      
          StackView {
              id: stackView
              initialItem: "HomeForm.ui.qml"
              anchors.fill: parent
          }
      

      this is my first page

      Page {
          id:mainPge
          width: 600
          height: 400
      
          title: qsTr("Home")
      
          Rectangle {
              id: rectangle
              //anchors.fill: parent
              width: mainPge.width
              height: 200
              color: "#ffffff"
          }
      }```
      J.HilkJ Offline
      J.HilkJ Offline
      J.Hilk
      Moderators
      wrote on last edited by
      #2

      @Nio74
      I would say, because mainPge is not the same width as window


      Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


      Q: What's that?
      A: It's blue light.
      Q: What does it do?
      A: It turns blue.

      Nio74N 1 Reply Last reply
      2
      • J.HilkJ J.Hilk

        @Nio74
        I would say, because mainPge is not the same width as window

        Nio74N Offline
        Nio74N Offline
        Nio74
        wrote on last edited by
        #3

        @J.Hilk said in Rectangle not conformed at window:

        @Nio74
        I would say, because mainPge is not the same width as window
        sorry i'm stupid

        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