Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. value of the width
Forum Updated to NodeBB v4.3 + New Features

value of the width

Scheduled Pinned Locked Moved Solved Mobile and Embedded
7 Posts 3 Posters 661 Views 2 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.
  • J Offline
    J Offline
    Jasur
    wrote on last edited by
    #1

    Hello all

    What is the value of the width? which is between stars
    parent.width i understand, it takes Window width
    import QtQuick 2.12
    import QtQuick.Window 2.12

    Window {
        visible: true
        width: 640
        height: 480
        title: qsTr("Hello World")
    
        Rectangle{
            id: root
            
            width: (parent.width-***width***)/2;
            height: 240;
    
            color: "#4A4A4A"
    

    Regards,
    Jasur

    JKSHJ 1 Reply Last reply
    0
    • J Jasur

      Hello all

      What is the value of the width? which is between stars
      parent.width i understand, it takes Window width
      import QtQuick 2.12
      import QtQuick.Window 2.12

      Window {
          visible: true
          width: 640
          height: 480
          title: qsTr("Hello World")
      
          Rectangle{
              id: root
              
              width: (parent.width-***width***)/2;
              height: 240;
      
              color: "#4A4A4A"
      

      Regards,
      Jasur

      JKSHJ Offline
      JKSHJ Offline
      JKSH
      Moderators
      wrote on last edited by
      #2

      @Jasur said in value of the width:

      What is the value of the width?

      What happens when you run your code?

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

      J 1 Reply Last reply
      0
      • JKSHJ JKSH

        @Jasur said in value of the width:

        What is the value of the width?

        What happens when you run your code?

        J Offline
        J Offline
        Jasur
        wrote on last edited by
        #3

        @JKSH Code runs without any errors, this example i taked from book https://qmlbook.github.io in the page: 32, and in this example from "parent.width" it subtracting "width", in the book it doesn't written what is the value of the "width". That is why i want to understand

        Regards,
        Jasur

        JKSHJ 1 Reply Last reply
        0
        • sierdzioS Offline
          sierdzioS Offline
          sierdzio
          Moderators
          wrote on last edited by
          #4

          That width comes from the Rectangle. Unless I get it wrong, it is a binding loop and QML engine will warn about it in console output.

          (Z(:^

          J 1 Reply Last reply
          2
          • J Jasur

            @JKSH Code runs without any errors, this example i taked from book https://qmlbook.github.io in the page: 32, and in this example from "parent.width" it subtracting "width", in the book it doesn't written what is the value of the "width". That is why i want to understand

            Regards,
            Jasur

            JKSHJ Offline
            JKSHJ Offline
            JKSH
            Moderators
            wrote on last edited by
            #5

            @Jasur said in value of the width:

            this example i taked from book https://qmlbook.github.io in the page: 32, and in this example from "parent.width" it subtracting "width", in the book it doesn't written what is the value of the "width". That is why i want to understand

            The book's example has x: (parent.width - width)/2 which is fine. It means, "This Rectangle's x value shall equal the parent's width minus this Rectangle's width, all divided by two".

            However, the code you posted above is not fine: width: (parent.width - width)/2 means "This Rectangle's width value shall equal the parent's width minus this Rectangle's width, all divided by two". With this code, it is impossible to calculate this Rectangle's width.

            Code runs without any errors

            When I run your code with Qt 5.14.1, I see the following error message in Qt Creator's Application Output pane:

            qrc:/main.qml:10:2: QML Rectangle: Binding loop detected for property "width"
            

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

            J 1 Reply Last reply
            1
            • JKSHJ JKSH

              @Jasur said in value of the width:

              this example i taked from book https://qmlbook.github.io in the page: 32, and in this example from "parent.width" it subtracting "width", in the book it doesn't written what is the value of the "width". That is why i want to understand

              The book's example has x: (parent.width - width)/2 which is fine. It means, "This Rectangle's x value shall equal the parent's width minus this Rectangle's width, all divided by two".

              However, the code you posted above is not fine: width: (parent.width - width)/2 means "This Rectangle's width value shall equal the parent's width minus this Rectangle's width, all divided by two". With this code, it is impossible to calculate this Rectangle's width.

              Code runs without any errors

              When I run your code with Qt 5.14.1, I see the following error message in Qt Creator's Application Output pane:

              qrc:/main.qml:10:2: QML Rectangle: Binding loop detected for property "width"
              
              J Offline
              J Offline
              Jasur
              wrote on last edited by
              #6

              @JKSH thank you, now i understand

              "This Rectangle's x value shall equal the parent's width minus this Rectangle's width, all divided by two".
              

              about my code, i am using Qt 5.12, maybe that is why i don't see any error and maybe i disabled LD_LIBRARY_PATH in the project, because of swrast, but tottaly it runs perfect.

              Thank you very much for explaining.

              Regards,
              Jasur

              1 Reply Last reply
              0
              • sierdzioS sierdzio

                That width comes from the Rectangle. Unless I get it wrong, it is a binding loop and QML engine will warn about it in console output.

                J Offline
                J Offline
                Jasur
                wrote on last edited by
                #7

                @sierdzio Thank you for explaining

                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