[Qt-interest] Unable to bring Scrollbar Properties in MDI subwindow of type QGraphicsView
John McClurkin
jwm at nei.nih.gov
Wed May 6 15:26:56 CEST 2009
Kamakshi Sivaraman wrote:
>
> Hi,
>
> Actually I tried using all the flags required to set the scrollbar for
> QGraphics View.
>
> The code snippet is follows :
>
> ChildFileApp::ChildFileApp(QList<structSysLogParams>
> lstSysLogParams,QGraphicsView *parent)
> :QGraphicsView(parent)
> {
>
> setHorizontalScrollBarPolicy(Qt::ScrollBarAsNeeded);
> setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded);
>
> . .. .. .. .. ...
> }
>
> Where ChildFileApp is the mdi subwindow called from MainWindow to show
> in MDI Area.
> I am painting in the GraphicsView and that painting is exceeding the
> size of the Subwindow file , then automatically the scroll bars should
> come,
> But its not happening.
>
> I hope this will give you some idea that what actually i am trying to say.
>
>
> Thanks & Regards,
> S.KAMAKSHI
> Larsen & Toubro Infotech Limited
> Whitefield,
> Bangalore -560066
>
Ok, If I understand correctly, what you seem to be trying to do is not
possible. You can't put scrollbars on a QMdiSubwindow. A QMdiSubwindow
is just a container that holds another widget. This can be anything from
a QWidget to a QMainWindow. What you do is create the object you want to
display in the QMdiArea with a NULL parent, then add it to the QMdiArea
with the command mdiArea->addSubWindow(object). In your case, you would
create a QGraphicsScene object, then a QGraphicsView object with a
pointer to the scene object as the argument, as described in the
QGraphicsView or QGraphicsScene documentation. You would set the
scrollbar policy on the QGraphicsView object. To add the QGraphcisView
object to the mdi area use a statement like:
mdiArea->addSubWindow(view);
where mdiArea is a pointer to your QMdiArea object and view is a pointer
to your QGraphicsView.
Since you set the scrollbar policy to Qt::ScrollBarAsNeeded, the
scrollbars will not appear unless you resize the mdiSubWindow so the
view object is smaller than the scene object, or you resize the scene
object so that is larger than the view object. I don't use the
QGraphicsView system so I don't know if the scene object will resize
automatically as objects are added or whether you have to manually
resize the scene. Take a look at the examples under
Qt-4.5.0/examples/graphicsview. Once you understand the conditions under
which the scrollbars of a QGraphicsView object are shown, you can
proceed to adding such an object to your QMdiArea.
More information about the Qt-interest-old
mailing list