Skip to content
This repository has been archived by the owner on May 24, 2021. It is now read-only.

Commit

Permalink
Invalidate the flow layout data on a layout request.
Browse files Browse the repository at this point in the history
This makes sure that the size hints cached by the layout items are
refreshed on the next layout.

This also removes the hack workaround for setting the layout widget.
The need for the hack was removed with the previous commit which
fixed a bug in QSingleWidgetLayout.
  • Loading branch information
sccolbert committed Nov 16, 2012
1 parent 8f7bf9d commit 1e91a54
Showing 1 changed file with 14 additions and 11 deletions.
25 changes: 14 additions & 11 deletions enaml/qt/qt_flow_item.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Copyright (c) 2012, Enthought, Inc.
# All rights reserved.
#------------------------------------------------------------------------------
from .qt.QtCore import QSize
from .qt.QtCore import QSize, QEvent
from .qt.QtGui import QFrame, QLayout
from .q_flow_layout import QFlowLayout, AbstractFlowWidget, FlowLayoutData
from .q_single_widget_layout import QSingleWidgetLayout
Expand Down Expand Up @@ -182,16 +182,19 @@ def setFlowWidget(self, widget):
"""
self._flow_widget = widget
try:
self.layout().setWidget(widget)
except AttributeError:
# XXX Hack! The layout type gets swapped out from under us
# during the destruction process when running on PyQt. It
# comes out as an instance of QWidgetItem. Need look into
# exactly what is causing this.
l = self.layout()
if widget is not None or isinstance(l, QSingleWidgetLayout):
raise
self.layout().setWidget(widget)

def event(self, event):
""" A custom event handler which handles LayoutRequest events.
When a LayoutRequest event is posted to this widget, it will
emit the `layoutRequested` signal. This allows an external
consumer of this widget to update their external layout.
"""
if event.type() == QEvent.LayoutRequest:
self._layout_data.dirty = True
return super(QFlowItem, self).event(event)


AbstractFlowWidget.register(QFlowItem)
Expand Down

0 comments on commit 1e91a54

Please sign in to comment.