PDA

View Full Version : how to prevent QGraphicsView() resizable by user



wagmare
24th February 2009, 07:10
hi friends ,
in normal QWidget() and QDialog() we can use
layout()->setSizeConstraint(QLayout::SetFixedSize); to prevent user to resize the teh window ..
how can i do it for graphicsView class ... there is no layout ..?

jryannel
24th February 2009, 08:25
But graphics view is normally contained in a parent widget, which has a layout. So you should try the magic there.
If graphics view is the top-level widget, guess you can use setFixedSize(QSize).

As graphics view is a scroll area it has a viewport widget (which actually displays the scene). So you might want to make that also fixed size and switch off the scrollbars. Haven't tried that part yet.

- Juergen

wagmare
24th February 2009, 09:32
But graphics view is normally contained in a parent widget, which has a layout. So you should try the magic there.
If graphics view is the top-level widget, guess you can use setFixedSize(QSize).

As graphics view is a scroll area it has a viewport widget (which actually displays the scene). So you might want to make that also fixed size and switch off the scrollbars. Haven't tried that part yet.

- Juergen
yes the view is the parent ...
i try setSizeConstraint but not setFixedSize(QSize) ...

to remove scroll bars i use
setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOf f);
setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff) ;

captiva
24th February 2009, 15:47
I had a slightly different problem, (setting the maximum-size after which a user cannot make a window larger). But this is almost the same as setting a fixed size.

I have an example in qt designer (log in to this forum so you can see the images) in the start post here (http://www.qtcentre.org/forum/f-qt-programming-2/t-maximumsize-by-layout-qmainwindow-18941.html), that works for simple dialogs, but not for qmainwindows (because these have their own layout handler).