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. why does the anchors.fill Unfill GroupBox in QML?
Forum Updated to NodeBB v4.3 + New Features

why does the anchors.fill Unfill GroupBox in QML?

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

    the follow Screenshots link.
    link text

    QQuickWidget* p = new QQuickWidget();
    QUrl source("qrc:/qml/groupbox.qml");
    p->setResizeMode(QQuickWidget::SizeRootObjectToView);
    p->setSource(source);
    
    import QtQuick 2.8
    import QtQuick.Controls 2.1
    import QtQuick.Layouts 1.2
    
    GroupBox{
            id:mainBox
            property string imagePath:"qrc:/resources/border.png"
            GridLayout{
                   anchors.centerIn:parent
                   anchors.fill:parent
                   rows:100
                   columns:100
                   columnSpacing:0
                   rowSpacing:0
                   GroupBox{
                         anchors.centerIn:parent
                         anchors.fill:parent    
                         BorderImage{
                                  id:bImage
                                  anchors.centerIn:parent
                                  anchors.fill:parent             
                                  source:imagePath
                        }               
                         Layout.column:0
                         Layout.row:0
                         Layout.columnSpan:100
                         Layout.rowSpan:100
                         Layout.margins:0                                   
                   }             
           }
    }
    
    ODБOïO 1 Reply Last reply
    0
    • M mirro

      the follow Screenshots link.
      link text

      QQuickWidget* p = new QQuickWidget();
      QUrl source("qrc:/qml/groupbox.qml");
      p->setResizeMode(QQuickWidget::SizeRootObjectToView);
      p->setSource(source);
      
      import QtQuick 2.8
      import QtQuick.Controls 2.1
      import QtQuick.Layouts 1.2
      
      GroupBox{
              id:mainBox
              property string imagePath:"qrc:/resources/border.png"
              GridLayout{
                     anchors.centerIn:parent
                     anchors.fill:parent
                     rows:100
                     columns:100
                     columnSpacing:0
                     rowSpacing:0
                     GroupBox{
                           anchors.centerIn:parent
                           anchors.fill:parent    
                           BorderImage{
                                    id:bImage
                                    anchors.centerIn:parent
                                    anchors.fill:parent             
                                    source:imagePath
                          }               
                           Layout.column:0
                           Layout.row:0
                           Layout.columnSpan:100
                           Layout.rowSpan:100
                           Layout.margins:0                                   
                     }             
             }
      }
      
      ODБOïO Offline
      ODБOïO Offline
      ODБOï
      wrote on last edited by
      #2

      hi

      @mirro said in why does the anchors.fill Unfill GroupBox in QML?:

      GridLayout{
      anchors.centerIn:parent
      anchors.fill:parent
      rows:100
      columns:100
      columnSpacing:0
      rowSpacing:0
      GroupBox{
      anchors.centerIn:parent // << can't use anchors here
      anchors.fill:parent //<<

      I am not sure this is the main issue but you can not use anchors inside an item that is managed by QML Layout, it leads to undefined behavior, use Layout.alignment instead

      note : when you say anchors.fill parent you don't need anchors.centerIn:parent because anchors.fill actually fills and centers in the parent

      1 Reply Last reply
      1

      • Login

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