summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJ-P Nurmi <jpnurmi@gmail.com>2009-09-30 18:18:23 (GMT)
committerAlexis Menard <alexis.menard@nokia.com>2009-12-03 09:36:54 (GMT)
commit3f18623dd8f26857d9af032c41095818f5346910 (patch)
tree35efdb96b3b7794e949c2d7af7004e665238e29f /src
parentb93000823d11575b6c30490ea97a2649a0119f86 (diff)
downloadQt-3f18623dd8f26857d9af032c41095818f5346910.zip
Qt-3f18623dd8f26857d9af032c41095818f5346910.tar.gz
Qt-3f18623dd8f26857d9af032c41095818f5346910.tar.bz2
Added QGraphicsWidget::autoFillBackground property.
This add a property to QGraphicsWidget to fill its background. QWidget has the same. Merge-Request: 1656 Reviewed-by: Alexis Menard <alexis.menard@nokia.com>
Diffstat (limited to 'src')
-rw-r--r--src/gui/graphicsview/qgraphicsscene.cpp2
-rw-r--r--src/gui/graphicsview/qgraphicswidget.cpp30
-rw-r--r--src/gui/graphicsview/qgraphicswidget.h4
-rw-r--r--src/gui/graphicsview/qgraphicswidget_p.h2
4 files changed, 38 insertions, 0 deletions
diff --git a/src/gui/graphicsview/qgraphicsscene.cpp b/src/gui/graphicsview/qgraphicsscene.cpp
index 8777cdc..82d2e2f 100644
--- a/src/gui/graphicsview/qgraphicsscene.cpp
+++ b/src/gui/graphicsview/qgraphicsscene.cpp
@@ -4187,6 +4187,8 @@ static void _q_paintItem(QGraphicsItem *item, QPainter *painter,
widgetItem->paintWindowFrame(painter, option, widget);
if (painterStateProtection)
painter->restore();
+ } else if (widgetItem->autoFillBackground()) {
+ painter->fillRect(option->exposedRect, widgetItem->palette().window());
}
widgetItem->paint(painter, option, widget);
diff --git a/src/gui/graphicsview/qgraphicswidget.cpp b/src/gui/graphicsview/qgraphicswidget.cpp
index fe569f4..1bb6375 100644
--- a/src/gui/graphicsview/qgraphicswidget.cpp
+++ b/src/gui/graphicsview/qgraphicswidget.cpp
@@ -967,6 +967,36 @@ void QGraphicsWidget::setPalette(const QPalette &palette)
}
/*!
+ \property QGraphicsWidget::autoFillBackground
+ \brief whether the widget background is filled automatically
+ \since 4.7
+
+ If enabled, this property will cause Qt to fill the background of the
+ widget before invoking the paint() method. The color used is defined by the
+ QPalette::Window color role from the widget's \l{QPalette}{palette}.
+
+ In addition, Windows are always filled with QPalette::Window, unless the
+ WA_OpaquePaintEvent or WA_NoSystemBackground attributes are set.
+
+ By default, this property is false.
+
+ \sa Qt::WA_OpaquePaintEvent, Qt::WA_NoSystemBackground,
+*/
+bool QGraphicsWidget::autoFillBackground() const
+{
+ Q_D(const QGraphicsWidget);
+ return d->autoFillBackground;
+}
+void QGraphicsWidget::setAutoFillBackground(bool enabled)
+{
+ Q_D(QGraphicsWidget);
+ if (d->autoFillBackground != enabled) {
+ d->autoFillBackground = enabled;
+ update();
+ }
+}
+
+/*!
If this widget is currently managed by a layout, this function notifies
the layout that the widget's size hints have changed and the layout
may need to resize and reposition the widget accordingly.
diff --git a/src/gui/graphicsview/qgraphicswidget.h b/src/gui/graphicsview/qgraphicswidget.h
index 05d3a49..d9723f8 100644
--- a/src/gui/graphicsview/qgraphicswidget.h
+++ b/src/gui/graphicsview/qgraphicswidget.h
@@ -82,6 +82,7 @@ class Q_GUI_EXPORT QGraphicsWidget : public QGraphicsObject, public QGraphicsLay
Q_PROPERTY(Qt::WindowFlags windowFlags READ windowFlags WRITE setWindowFlags)
Q_PROPERTY(QString windowTitle READ windowTitle WRITE setWindowTitle)
Q_PROPERTY(QRectF geometry READ geometry WRITE setGeometry)
+ Q_PROPERTY(bool autoFillBackground READ autoFillBackground WRITE setAutoFillBackground)
public:
QGraphicsWidget(QGraphicsItem *parent = 0, Qt::WindowFlags wFlags = 0);
~QGraphicsWidget();
@@ -103,6 +104,9 @@ public:
QPalette palette() const;
void setPalette(const QPalette &palette);
+ bool autoFillBackground() const;
+ void setAutoFillBackground(bool enabled);
+
void resize(const QSizeF &size);
inline void resize(qreal w, qreal h) { resize(QSizeF(w, h)); }
QSizeF size() const;
diff --git a/src/gui/graphicsview/qgraphicswidget_p.h b/src/gui/graphicsview/qgraphicswidget_p.h
index eb53649..d2f898e 100644
--- a/src/gui/graphicsview/qgraphicswidget_p.h
+++ b/src/gui/graphicsview/qgraphicswidget_p.h
@@ -80,6 +80,7 @@ public:
inSetGeometry(0),
polished(0),
inSetPos(0),
+ autoFillBackground(0),
focusPolicy(Qt::NoFocus),
focusNext(0),
focusPrev(0),
@@ -172,6 +173,7 @@ public:
quint32 inSetGeometry : 1;
quint32 polished: 1;
quint32 inSetPos : 1;
+ quint32 autoFillBackground : 1;
// Focus
Qt::FocusPolicy focusPolicy;