|  | Home · All Namespaces · All Classes · Main Classes · Grouped Classes · Modules · Functions |

# window.cpp Example File
graphicsview/basicgraphicslayouts/window.cpp

     /****************************************************************************
     **
     ** Copyright (C) 2008-$THISYEAR$ $TROLLTECH$. All rights reserved.
     **
     ** This file is part of the $MODULE$ of the Qt Toolkit.
     **
     ** $TROLLTECH_DUAL_LICENSE$
     **
     ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
     ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
     **
     ****************************************************************************/

     #include "window.h"
     #include "layoutitem.h"

     Window::Window(QGraphicsWidget *parent) : QGraphicsWidget(parent, Qt::Window)
     {
         QGraphicsLinearLayout *windowLayout = new QGraphicsLinearLayout(Qt::Vertical);
         QGraphicsLinearLayout *linear = new QGraphicsLinearLayout(windowLayout);
         LayoutItem *item = new LayoutItem;
         linear->addItem(item);
         linear->setStretchFactor(item, 1);

         item = new LayoutItem;
         linear->addItem(item);
         linear->setStretchFactor(item, 3);
         windowLayout->addItem(linear);

         QGraphicsGridLayout *grid = new QGraphicsGridLayout(windowLayout);
         item = new LayoutItem;
         grid->addItem(item, 0, 0, 4, 1);
         item = new LayoutItem;
         item->setMaximumHeight(item->minimumHeight());
         grid->addItem(item, 0, 1, 2, 1, Qt::AlignVCenter);
         item = new LayoutItem;
         item->setMaximumHeight(item->minimumHeight());
         grid->addItem(item, 2, 1, 2, 1, Qt::AlignVCenter);
         item = new LayoutItem;
         grid->addItem(item, 0, 2);
         item = new LayoutItem;
         grid->addItem(item, 1, 2);
         item = new LayoutItem;
         grid->addItem(item, 2, 2);
         item = new LayoutItem;
         grid->addItem(item, 3, 2);
         windowLayout->addItem(grid);

         setLayout(windowLayout);
         setWindowTitle(tr("Basic Graphics Layouts Example"));

     }