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. Rectangles & padding

Rectangles & padding

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

    Hello

    it seems I'm either very stupid in finding this information or it truly doesnt exist.
    Do rectangles have a padding property or how is padding realized with the current functionality?

    Of Course you can nest 2 rectangles to get this effect and use margins in the inner rectangle
    but thats kind of messes up what I'm trying to do.

    thanks for your time.

    1 Reply Last reply
    1
    • C Offline
      C Offline
      chrisadams
      wrote on last edited by
      #2

      Padding what? Between what and what? If you're anchoring it to something else, you can specify margins / spacing via the anchors.

      Cheers,
      Chris.

      1 Reply Last reply
      0
      • M Offline
        M Offline
        mesotes
        wrote on last edited by
        #3

        uhm..

        something like this:

        @
        Rectangle{
        padding:10

        Rectangle{
        anchors.fill: parent
        }
        }
        @

        That every Child inside a, say, Rectangle (Row, Column,.. etc) component will be positioned inside that said rectangle with an offset of 10 from each side..

        that inner rectangle will be 20 px short in length and height in this example.

        like the padidng property in css

        1 Reply Last reply
        0
        • C Offline
          C Offline
          chrisadams
          wrote on last edited by
          #4

          It is the anchors which define how the child rectangle fills the parent rectangle. Remember, in QML, just because an object instance is declared within another one does NOT mean that it is visually located inside that other one. The positioning (either via anchors, or some other positioning method) define where it "appears" and thus the positioning also defines the spacing / padding.

          So, to implement what you want, just add an "anchors.margins: 10" to your anchors declaration. Note that the margin can also be specified separately for each edge; see http://doc-snapshot.qt-project.org/qt5-stable/qtquick/qtquick-positioning-anchors.html for more information.

          Cheers,
          Chris.

          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