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. [SOLVED] Problem with anchors within tabs
QtWS25 Last Chance

[SOLVED] Problem with anchors within tabs

Scheduled Pinned Locked Moved QML and Qt Quick
3 Posts 2 Posters 706 Views
  • 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.
  • J Offline
    J Offline
    jrikken
    wrote on last edited by
    #1

    Hi all,

    I am trying to create a simple GUI with QML, when the following occured:

    • Text can be aligned using anchors under the ApplicationWindow

    • Copying the same code snipped (i just changed the id's) inside a Tab results in an error: ReferenceError: textC is not defined. This results in textC being placed on top of textB (see also picture)

    QML code:
    @import QtQuick 2.3
    import QtQuick.Controls 1.2
    import QtQuick.Dialogs 1.2
    import QtQuick.Layouts 1.1

    ApplicationWindow {
    id: applicationWindow1
    visible: true
    width: 640
    height: 480
    title: qsTr("MyApp")

    Text{
        id: textA
        text: qsTr("Test A")
    }
    Text{
        id: textB
        text: qsTr("Test B")
        anchors.left: textA.right
    }
    
    TabView{
        anchors.top: textB.bottom
        Tab{
            title: qsTr("TEST")
            Text{
                id: textC
                text: qsTr("Test C")
            }
            Text{
                id: textD
                text: qsTr("Test D")
                anchors.left: textC.right
            }
        }
    }
    

    }@

    Picture:
    !http://s2.postimg.org/hzvyntxfd/info.png(info)!

    I was convinced this should work because textB and textC are living under the same parent.

    Am i missing something or is this just not allowed in QML?

    Thanks in advance!

    As they say in the Netherlands: gaat niet bestaat niet

    1 Reply Last reply
    0
    • dheerendraD Offline
      dheerendraD Offline
      dheerendra
      Qt Champions 2022
      wrote on last edited by
      #2

      Tab is inherited from Loader. It allows load one component. You will hit this issue in any platform. Just try include everything under one rectangle in tab

      @Tab {
      Rectangle {
      Text {}
      Text{}
      }
      }

      @

      This should work

      Dheerendra
      @Community Service
      Certified Qt Specialist
      http://www.pthinks.com

      1 Reply Last reply
      0
      • J Offline
        J Offline
        jrikken
        wrote on last edited by
        #3

        Thanks! Works like a charm!

        As they say in the Netherlands: gaat niet bestaat niet

        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