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

Problem with setParent() for a child of a QDialog embedded in a QGraphicsView

    XMLWordPrintable

Details

    Description

      With the attached example program, I get the following behavior:

      == First round ==

      • start the program
        => output
        combo box constructor
        list widget constructor
      • click the check box => the combobox appears
      • click the check box again => the combobox disappears
      • close the dialog
        => no more output

      This is correct, as finally the combo box does not have a parent which
      destroys it

      == Second round ==

      • start the program
        => output
        combo box constructor
        list widget constructor
      • click the check box => the combobox appears
      • click on the combobox => the dropdown appears
      • click again => the dropdown disappears
      • click the check box again => the combobox disappears
      • close the dialog
        => output
        list widget destructor

      This is not correct. The combo box does not have a parent, and the list
      widget is a child
      (or grandchild) of the combo box and should at this moment be independent
      of the graphics view.

      In a real world program this can lead to crashes due to widgets which are
      supposed to be
      recycled over multiple instantiations of a graphics view being destroyed
      behind the
      applications's back (note: the subclassing of QListWidget and QComboBox in
      the example
      program is just for the purpose of printing debugging output. The behavior
      is independent
      of this).

      The reason for this behavior is either in the hide_helper() of QWidget or
      in the setParent().
      Showing a child of a dialog embedded in a graphics view automatically
      creates a corresponding
      proxy widget. Then, either hiding this child should destroy the proxy
      widget, or the setParent()
      of the parent dialog should do this.

      This was tested on both Qt 4.4.x and Qt 4.5.0 on X11.

      Attachments

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

        Activity

          People

            bjnilsen Bjørn Erik Nilsen
            janichol Andy Nichols
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes