Trolltech Home | Qt4-preview-feedback Home | Recent Threads | All Threads | Author | Date
All threads index page 1

Qt4-preview-feedback Archive, January 2008
QGraphicsGridLayout problem


Message 1 in thread

Hello.
I'm trying the new Graphics View layout framework and have found what seems
to be a bug in QGraphicsGridLayout:
Changing an item's preferred size after its layout has been activated
doesn't do anything.
Here is a sample code to reproduce this problem:

QGraphicsGridLayout* layout = new QGraphicsGridLayout();
layout->addItem(item1, 0, 0);
layout->addItem(item2, 1, 0);
...

Later on (after a display or in fact an activate() call on the layout) I
call:

item1->setPreferredSize(2*item1->preferredSize())
item1->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum,
QSizePolicy::DefaultType);
item1->updateGeometry();
layout->invalidate();

but it doesn't change the item's size.
If I call the same code before displaying the scene the item's size is
correctly updated.
I'm using Qt version 4.4.0-tp1 on Windows platform.

Does anybody has an idea on this ?

Thanks,

Sebastien Grignard
Software Engineer
R&D OrthoPilot Software
Aesculap SAS

********************************************************************************
The information contained in this communication is confidential, may be
attorney-client privileged, may constitute inside information, and is intended
only for the use of the addressee. It is the property of the company of the
sender of this e-mail. Unauthorized use, disclosure, or copying of this
communication or any part thereof is strictly prohibited and may be unlawful.
If you have received this communication in error, please notify us immediately
by return e-mail and destroy this communication and all copies thereof,
including all attachments.
********************************************************************************

To unsubscribe - send "unsubscribe" in the subject to qt4-preview-feedback-request@xxxxxxxxxxxxx


Message 2 in thread

Hello again.

After looking in the QGraphicsGridLayout's code the problem seems that
invalidate() doesn't call invalidate() on the internal QGridLayoutEngine
instance.
Calling setRowSpacing(0, rowSpacing(0)) (which calls invalidate() on the
QGridLayoutEngine) on the layout between the calls to setPreferredSize and
invalidate() make it works.

Sebastien Grignard
Software Engineer
R&D OrthoPilot Software
Aesculap SAS

Sebastien Grignard wrote :

> Hello.
> I'm trying the new Graphics View layout framework and have found what
seems
> to be a bug in QGraphicsGridLayout:
> Changing an item's preferred size after its layout has been activated
> doesn't do anything.
> Here is a sample code to reproduce this problem:
>
> QGraphicsGridLayout* layout = new QGraphicsGridLayout();
> layout->addItem(item1, 0, 0);
> layout->addItem(item2, 1, 0);
> ...
>
> Later on (after a display or in fact an activate() call on the layout) I
> call:
>
> item1->setPreferredSize(2*item1->preferredSize())
> item1->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum,
> QSizePolicy::DefaultType);
> item1->updateGeometry();
> layout->invalidate();
>
> but it doesn't change the item's size.
> If I call the same code before displaying the scene the item's size is
> correctly updated.
> I'm using Qt version 4.4.0-tp1 on Windows platform.
>

********************************************************************************
The information contained in this communication is confidential, may be
attorney-client privileged, may constitute inside information, and is intended
only for the use of the addressee. It is the property of the company of the
sender of this e-mail. Unauthorized use, disclosure, or copying of this
communication or any part thereof is strictly prohibited and may be unlawful.
If you have received this communication in error, please notify us immediately
by return e-mail and destroy this communication and all copies thereof,
including all attachments.
********************************************************************************

To unsubscribe - send "unsubscribe" in the subject to qt4-preview-feedback-request@xxxxxxxxxxxxx


Message 3 in thread

sebastien.grignard@xxxxxxxxxx wrote:
> After looking in the QGraphicsGridLayout's code the problem seems that
> invalidate() doesn't call invalidate() on the internal QGridLayoutEngine
> instance.
> Calling setRowSpacing(0, rowSpacing(0)) (which calls invalidate() on the
> QGridLayoutEngine) on the layout between the calls to setPreferredSize and
> invalidate() make it works.

Hi, Sebastien, sorry for the late reply.

You're perfectly right, QGraphicsGridLayout didn't reimplement invalidate().
Here's a patch that fixes this problem:

--- qgraphicsgridlayout.cpp  1970-01-01 01:00:00.000000000
+++ qgraphicsgridlayout.cpp  2007/12/07 18:06:34.000000000
@@ -526,6 +526,16 @@
 }

 /*!
+    \reimp
+*/
+void QGraphicsGridLayout::invalidate()
+{
+    Q_D(QGraphicsGridLayout);
+    d->engine.invalidate();
+    QGraphicsLayout::invalidate();
+}
+
+/*!
     Sets the bounding geometry of the grid layout to \a rect.
 */
 void QGraphicsGridLayout::setGeometry(const QRectF &rect)

--- qgraphicsgridlayout.h  2007/12/07 18:06:34.000000000
+++ qgraphicsgridlayout.h  2007/12/11 16:01:01.000000000
@@ -88,6 +88,8 @@
     QGraphicsLayoutItem *itemAt(int index) const;
     void removeAt(int index);

+    void invalidate();
+
     // inherited from QGraphicsLayoutItem
     void setGeometry(const QRectF &rect);
     QSizeF sizeHint(Qt::SizeHint which, const QSizeF &constraint =
QSizeF()) const;


-- 
 [ signature omitted ]