Trolltech Home | Qt-interest Home | Recent Threads | All Threads | Author | Date
All threads index page 3

Qt-interest Archive, September 2007
replacing the QLayout


Message 1 in thread

Hi,

I'm involved in writing an application that displays images.  I might
have, for example, four images displayed 2x2.  The plan is to create a
QWidget, set a QGridLayout, then add the four widgets appropriately.

Suppose I want to change to a 1x4 layout.  It looks like we have to
delete the existing layout, add the new one, and then re-add the four
QWidgets.

Is that the recommended strategy?  There's no issue with having the
widget temporarily without a layout?  Are we overlooking something?
Is there any utility function somewhere that has already coded this
kind of thing?

Thanks,
-Steve

Attachment:

Attachment: signature.asc
Description: Digital signature


Message 2 in thread

Steve M. Robbins wrote:

> I'm involved in writing an application that displays images.  I might
> have, for example, four images displayed 2x2.  The plan is to create a
> QWidget, set a QGridLayout, then add the four widgets appropriately.
> 
> Suppose I want to change to a 1x4 layout.  It looks like we have to
> delete the existing layout, add the new one, and then re-add the four
> QWidgets.
> 
> Is that the recommended strategy?  There's no issue with having the
> widget temporarily without a layout?  Are we overlooking something?
> Is there any utility function somewhere that has already coded this
> kind of thing?
Quite a while back I coded such a thing. It worked with Qt 2.x (to my
defense: it was for a Qt/e application). The idea was that I created my own
layout class, that contained a set of other layout classes and turn on the
appropriate one through a slot. Of course, it also hid & showed widgets
that were in one layout but not in the other. Worked like a charm. I think
I have posted the code on the list before, but I could do it again if
you're interested and can't find it in the archives. You may be able to
port it to Qt <whatever you're using>.

Regards,

André
-- 
 [ signature omitted ] 

Message 3 in thread

Hello André,

Thanks for the note.  

On Sat, Sep 15, 2007 at 10:43:02AM +0200, André Somers wrote:
> Steve M. Robbins wrote:
> 
> > I'm involved in writing an application that displays images.  I might
> > have, for example, four images displayed 2x2.  The plan is to create a
> > QWidget, set a QGridLayout, then add the four widgets appropriately.
> > 
> > Suppose I want to change to a 1x4 layout.  It looks like we have to
> > delete the existing layout, add the new one, and then re-add the four
> > QWidgets.

I should also mention that we don't know up front the set of possible
layouts.  We'd like to support, say, MxN grids for any value of M and
N.  And there will be a few non-grid layouts as well.  For this
reason, I don't think we want a design like André's MultiLayout [1]
that requires knowing all possible layouts up front.

We're working with Qt 4.3.


> Quite a while back I coded such a thing. It worked with Qt 2.x (to my
> defense: it was for a Qt/e application). The idea was that I created my own
> layout class, that contained a set of other layout classes and turn on the
> appropriate one through a slot. Of course, it also hid & showed widgets
> that were in one layout but not in the other. Worked like a charm. I think
> I have posted the code on the list before, but I could do it again if
> you're interested and can't find it in the archives. You may be able to
> port it to Qt <whatever you're using>.

I did a quick google and came up with a thread from 2004 [1].  Is
that what you meant?  I didn't see any link to code there.


[1] http://lists.trolltech.com/qt-interest/2004-01/thread00746-0.html

Thanks,
-Steve

Attachment:

Attachment: signature.asc
Description: Digital signature


Message 4 in thread

Steve,

The "Dynamic Layout" Qt example seems to just remove the widgets and re-add
them in the correct order. In my application, we have to relayout certain
widgets and we use the same strategy. I don't know of any other tricks for
doing this.

Tom

On 9/14/07, Steve M. Robbins <steve@xxxxxxxxx> wrote:
>
> Hi,
>
> I'm involved in writing an application that displays images.  I might
> have, for example, four images displayed 2x2.  The plan is to create a
> QWidget, set a QGridLayout, then add the four widgets appropriately.
>
> Suppose I want to change to a 1x4 layout.  It looks like we have to
> delete the existing layout, add the new one, and then re-add the four
> QWidgets.
>
> Is that the recommended strategy?  There's no issue with having the
> widget temporarily without a layout?  Are we overlooking something?
> Is there any utility function somewhere that has already coded this
> kind of thing?
>
> Thanks,
> -Steve
>
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.6 (GNU/Linux)
>
> iD8DBQFG6wAF0i2bPSHbMcURAna6AJ9cusQ4gZ789cr4s+MEx3k1I2bsJgCbBegA
> Gfpadu5fi8w/Pm/ZedVFqtU=
> =LOjs
> -----END PGP SIGNATURE-----
>
>