summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorBjørn Erik Nilsen <bjorn.nilsen@nokia.com>2009-08-20 20:30:48 (GMT)
committerBjørn Erik Nilsen <bjorn.nilsen@nokia.com>2009-08-20 20:30:48 (GMT)
commitde69a7c1dd558b4e9a119f2c63479d11cdbcaaf3 (patch)
treeb03e03e676470648dc3a4cf37a2ccdce46fc1a84 /src
parent547224c750a090222836f90532ff405ed5171358 (diff)
downloadQt-de69a7c1dd558b4e9a119f2c63479d11cdbcaaf3.zip
Qt-de69a7c1dd558b4e9a119f2c63479d11cdbcaaf3.tar.gz
Qt-de69a7c1dd558b4e9a119f2c63479d11cdbcaaf3.tar.bz2
Delete existing graphics effect when setting a new one.
Before we had to delete the existing effect before setting a new one (in the same fashion as QLayout behaves). This feels wrong and we should automatically delete it instead.
Diffstat (limited to 'src')
-rw-r--r--src/gui/graphicsview/qgraphicsitem.cpp11
-rw-r--r--src/gui/kernel/qwidget.cpp17
2 files changed, 18 insertions, 10 deletions
diff --git a/src/gui/graphicsview/qgraphicsitem.cpp b/src/gui/graphicsview/qgraphicsitem.cpp
index 5fa1748..b8187e7 100644
--- a/src/gui/graphicsview/qgraphicsitem.cpp
+++ b/src/gui/graphicsview/qgraphicsitem.cpp
@@ -2240,9 +2240,8 @@ QGraphicsEffect *QGraphicsItem::graphicsEffect() const
/*!
Sets \a effect as the item's effect. If there already is an effect installed
- on this item, QGraphicsItem won't let you install another. You must first
- delete the existing effect (returned by graphicsEffect()) before you can call
- setGraphicsEffect() with the new effect.
+ on this item, QGraphicsItem will delete the existing effect before installing
+ the new \a effect.
If \a effect is the installed on a different item, setGraphicsEffect() will remove
the effect from the item and install it on this item.
@@ -2257,10 +2256,8 @@ void QGraphicsItem::setGraphicsEffect(QGraphicsEffect *effect)
return;
if (d_ptr->graphicsEffect && effect) {
- // ### This seems wrong - the effect should automatically be deleted.
- qWarning("QGraphicsItem::setGraphicsEffect: Attempting to set QGraphicsEffect "
- "%p on %p, which already has an effect installed", effect, this);
- return;
+ delete d_ptr->graphicsEffect;
+ d_ptr->graphicsEffect = 0;
}
if (!effect) {
diff --git a/src/gui/kernel/qwidget.cpp b/src/gui/kernel/qwidget.cpp
index a9ef6aa..6928761 100644
--- a/src/gui/kernel/qwidget.cpp
+++ b/src/gui/kernel/qwidget.cpp
@@ -4870,6 +4870,18 @@ QGraphicsEffect *QWidget::graphicsEffect() const
return d->graphicsEffect;
}
+/*!
+ Sets \a effect as the widget's effect. If there already is an effect installed
+ on this widget, QWidget will delete the existing effect before installing
+ the new \a effect.
+
+ If \a effect is the installed on a different widget, setGraphicsEffect() will remove
+ the effect from the widget and install it on this widget.
+
+ \note This function will apply the effect on itself and all its children.
+
+ \since 4.6
+*/
void QWidget::setGraphicsEffect(QGraphicsEffect *effect)
{
Q_D(QWidget);
@@ -4877,9 +4889,8 @@ void QWidget::setGraphicsEffect(QGraphicsEffect *effect)
return;
if (d->graphicsEffect && effect) {
- // ### This seems wrong - the effect should automatically be deleted.
- qWarning("already set");
- return;
+ delete d->graphicsEffect;
+ d->graphicsEffect = 0;
}
if (!effect) {