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

Qt-interest Archive, March 2002
qcanvas on designer


Message 1 in thread

hello,
i don't understand how can i work qcanvas class on designer. I found no
documentation about it....
How to make a field (on designer of course)...just that and no more. For
example transform a qframe into a qcanvas field.
Thanks for help....

stephane B


Message 2 in thread

On Tue, 19 Mar 2002 12:50:23 +0100
"stepahne B" <isom@nerim.net> wrote:

> hello,
> i don't understand how can i work qcanvas class on designer. I found no
> documentation about it....
> How to make a field (on designer of course)...just that and no more. For
> example transform a qframe into a qcanvas field.

This is easy enough. In fact you cannot "transform" the frame, but you can
simply add widgets to it. Usually you will only add one, but you can use
the frame to reserve some space and use it at your leisure afterwards.

In designer, put a basic, no-style frame where you intend to have your
canvas. Give it a name, say, ui_canvas_frame_, so you can access it later
on in your code. Then when you initialize your dialog/widget (typically in
the constructor) you can do something like :

MyWidget::MyWidget( ... ) {
 ...
 // create a layout for the empty frame so the canvas will be correctly
resized QHBoxLayout* layout = new QHBoxLayout(ui_canvas_frame_); 

 // create the canvas and add it to the layout
 QCanvas* canvas = new QCanvas(ui_canvas_frame_, ...);
 layout->add(canvas);
 // do whatever you want with the canvas
 ...
}

This approach works with any kind of widget you do not have in Designer.
Note that : - if the frame is set in a layout in Designer, this layout
will manage the frame itself but, of course, not its contents. This is why
you need to add another layout inside your frame, - if you want your
"final" widget to have a minimum size, you should set this in the frame

-- 
 [ signature omitted ]