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

"Paste Error": "Cannot paste widgets. Designer could not find a container without a layout to paste into." occurs frequently in simple cut & paste situations

    XMLWordPrintable

Details

    Description

      Whenever we try to paste a widget into another widget in Qt Designer that uses any non-broken layout, it fails.

      I'm defining "paste target" below as the object that is selected in Qt designer when the user chooses Paste - to cause these examples, paste targets have any non-broken layout (I tested with horizontal, vertical, grid and form layouts).

      To use Microsoft Word as an example, if you copy a block of text (or an object), then you right click somewhere else and click "Paste", the object will show in that location (even if it's inside a parent-like canvas). Of course, MS Word doesn't have the concept of horizontal layouts, but text is generally in a sort of "flow" layout.

      In Qt, the equivalent action can fail in one of two ways.
      (a) If the paste target has a parent that has a broken layout, the widget gets pasted into the parent of the paste target, rather than into the selected paste target. For example, say the the top level widget is named "centralLayout" and has a broken layout, with a child called "horizontalLayout". If the user selects "horizontalLayout", right clicks, and selects paste, the pasted widget ends up in "centralLayout", not in horizontalLayout where the user requested the action.
      (b) If the paste target does not have any parents with broken layouts, the paste fails with an obscure error message (see attached image "CannotPasteWidgetsScreenShot.png") "Paste Error" "Cannot Paste widgets. Designer could not find a container without a layout to paste into."

      In practice, this heavily limits the ability to use cut and paste. Since paste only can be made into broken widgets, there are many well-formed layouts that cannot be pasted into anywhere in the .ui file.

      It appears that the only way to move objects around into a parent with a layout is is drag and drop, since paste will not work. This can become particularly restrictive if the target layout is compressed to a very small point. See example screenshot "LayoutWithAVerySmallTarget.png" - the "horizontalLayout" is only 2 pixels high, so if a user wanted to move "label" into "horizontalLayout" they would have to drag and drop into a two pixel target, while the target is mostly obscured by the shadow image during the drag & drop operation. The workaround we guessed at to make this quicker was to try to cut & paste it - but cut and paste will fail with an "Paste Error" message.

      After practice, I'm able to hit a 2 pixel target when doing drag and drop, but I had trouble teaching this to another Qt user at my organization, who kept thinking that his drag & drop had failed (he thought he had drag & dropped the object on top of the target but had missed the 2 pixel height). The user tried with cut & paste (just as I originally did) and when he got the paste error, the user incorrectly believed that Qt was voiding his attempts to reparent the object as something invalid in Qt. He seemed to perceive this as a limitation of the framework rather than as a precision error.

      As suggested in http://bugreports.qt.nokia.com/browse/QTCREATORBUG-623 this is a resubmit of that suggestion to the correct project.

      Attachments

        Issue Links

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

          Activity

            People

              kleint Friedemann Kleint
              aaronpowers Aaron Powers
              Votes:
              2 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:

                Gerrit Reviews

                  There are no open Gerrit changes