[Qt-interest] Is it okay to put a QRect (geometry) into a QVariant?
Robert Hairgrove
evorgriahr at hispeed.ch
Mon Feb 2 23:17:47 CET 2009
Niels Dekker - no return address wrote:
> My program basically does settings.setValue("geometry",geometry()), to
> store the geometry of a window into the Windows registry. Is that okay?
According to the docs, it is "best practice" to do a QWidget::resize()
and then QWidget::move() instead of setGeometry(). This is mostly due to
some issues with the X11 window manager, I believe. On Windows, it
might not matter because there is a nice API function which takes a
rectangle as argument (Get/SetWindowPosition).
At any rate, you might want to consider storing these coordinates
(position and size) separately as QSize and QPoint which pose no
problems for QVariant (and for QSettings). As a last resort, it is
always possible to store, and later read, four separate integer values
from a QSettings object.
> I'm asking, because the geometry is a QRect, and QSettings::setValue
> expects a QVariant as argument. If I understand correctly, QRect may
> not supported by QVariant, depending on QT_NO_GEOM_VARIANT.
>
> http://www.qtsoftware.com/developer/task-tracker/index_html?method=entry&id=83131
> says:
>
> "The define QT_NO_GEOM_VARIANT basically prevents you to put geometry
> classes into QVariant..."
>
> Can you please explain why?
>
> Kind regards,
>
> --
> Niels Dekker
> http://www.xs4all.nl/~nd/dekkerware
> Scientific programmer at LKEB, Leiden University Medical Center
More information about the Qt-interest-old
mailing list