Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-59380

Popup with margins opened at wrong position

    XMLWordPrintable

Details

    • Bug
    • Resolution: Invalid
    • Not Evaluated
    • None
    • 5.7.0, 5.8.0
    • Quick: Controls 2
    • None
    • Mageia Linux Cauldron x86_64, Plasma 5

    Description

      If popup use margins, it position after open() is wrong. To reproduce, run test program. After window resize popup moves to the center.

      Test program:

      import QtQuick 2.7
      import QtQuick.Controls 2.0
      
      ApplicationWindow {
          visible: true
          width: 400
          height: 300
      
          Button {
              anchors.horizontalCenter: parent.horizontalCenter
              anchors.bottom: parent.bottom
              text: "Open popup"
              onClicked: popup.open()
      
              Popup {
                  id: popup
      
                  property point position: parent.mapFromItem(null,
                                                              (ApplicationWindow.window.width - width) / 2,
                                                              (ApplicationWindow.window.height - height) / 2)
      
                  x: position.x
                  y: position.y
                  margins: 20
      
                  contentItem: Item {
                      implicitWidth: 100
                      implicitHeight: 100
                      Rectangle {
                          anchors.fill: parent
                          color: "skyblue"
                      }
                  }
              }
          }
      }
      

      The workaround is to use code like this for the position calculation:
      (main.width - width) / 2 + visible - visible

      Attachments

        Issue Links

          No reviews matched the request. Check your Options in the drop-down menu of this sections header.

          Activity

            People

              laknoll Lars Knoll
              krnekit Nikita Krupenko
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes