can't get qgraphicsgridlayout to resize properly

Marco Martin notmart at gmail.com
Tue Aug 25 13:15:50 CEST 2009


On Tuesday 25 August 2009, Amritpal Bath wrote:
> I've got a Plasma::Applet containing a QGraphicsGridLayout, which has a
> couple of QGraphicsWidgets (QLabels via QGraphicsProxyWidget).
>
> The text in my layout gets updated periodically after running an external
> process, but I can't quite get the resizing to work properly.  I've
> attached a similar example, with a layout containing two QPushButtons.
>
> I try to adjust the height of the buttons, layout, AND the Applet, but
> nothing I've tried will make the buttons taller.  It sounds like maybe I'm
> missing something about QSizePolicy, but I'm not sure.
>
> Can someone please explain the relationship between Plasma::Applet and
> QLayout, and why the attached code does not make the buttons taller?  As
> you can see from the .cpp, I've tried most/all things I could find.
>
> Thanks!
first of all don't use qgraphicsproxywidgets by hand, use the plasma widgets 
that are already there, Label, PushButton etc (they're proxywidgets too)

don't try to compute the size by hand, use sizehints, like 
Appelt::effectiveSizeHint(Qt::PreferredSize)

size hints of qlabels appear to be in no relation with the text size (and you 
can't acces the indide qtextdocument, so no way to fetch the size of the text)
if this is really needed use Plasma::TextBrowser with disabled scrollbars, 
that should have meaningful size hints

-- 
Marco Martin


More information about the Plasma-devel mailing list