diff options
author | Mika Salmela <mika.salmela@digia.com> | 2013-10-11 14:08:27 +0300 |
---|---|---|
committer | Mika Salmela <mika.salmela@digia.com> | 2013-10-11 14:13:03 +0300 |
commit | 34c345b024be424873bbb8b3c83414eea2bc7523 (patch) | |
tree | dcf946045d4002e082c3a2f291590b987c00506a /examples | |
parent | 4038e5eb11b585806fd63fa4fdb74be1d0f62a4b (diff) |
Add application creation chapter to surface example.
Change-Id: Ia787f1ebd5b5d9e781f1d95c4747045e6d2e4a94
Reviewed-by: Miikka Heikkinen <miikka.heikkinen@digia.com>
Diffstat (limited to 'examples')
-rw-r--r-- | examples/surface/doc/src/surface.qdoc | 23 | ||||
-rw-r--r-- | examples/surface/main.cpp | 22 |
2 files changed, 34 insertions, 11 deletions
diff --git a/examples/surface/doc/src/surface.qdoc b/examples/surface/doc/src/surface.qdoc index 4a0ce794..12271fb8 100644 --- a/examples/surface/doc/src/surface.qdoc +++ b/examples/surface/doc/src/surface.qdoc @@ -36,7 +36,28 @@ \endlist \image surface-example.png - \section1 Setting up proxies and setting the data + \section1 Creating the application + + First, in \c main.cpp, we create a QApplication, instantiate Q3DSurface and a window container + for it: + + \snippet ../examples/surface/main.cpp 0 + + The call to QWidget::createWindowContainer is required, as all data visualization types + (Q3DBars, Q3DScatter, Q3DSurface) inherit QWindow. Any class inheriting QWindow cannot be used + as a widget any other way. + + Then we'll create horizontal and vertical layouts. We'll add the graph with the container and + the vertical layout into the horizontal one: + + \snippet ../examples/surface/main.cpp 1 + + The rest of the code in \c main.cpp is creating control widgets for features in Q3DSurface. We + have separated code for changing these features into \c surfacegraph.cpp and only connect + signals from widgets into methods in \c surfacegraph.cpp. Next chapter explains more + about using Q3DSurface. + + \section1 Setting up proxies and data First we instantiate a new QSurfaceDataProxy: diff --git a/examples/surface/main.cpp b/examples/surface/main.cpp index cd26eb8d..69babe8a 100644 --- a/examples/surface/main.cpp +++ b/examples/surface/main.cpp @@ -32,26 +32,28 @@ int main(int argc, char **argv) { + //! [0] QApplication app(argc, argv); - - QWidget *widget = new QWidget; - QHBoxLayout *hLayout = new QHBoxLayout(widget); - QVBoxLayout *vLayout = new QVBoxLayout(); - vLayout->setAlignment(Qt::AlignTop); - Q3DSurface *graph = new Q3DSurface(); - QSize screenSize = graph->screen()->size(); - QWidget *container = QWidget::createWindowContainer(graph); + //! [0] + + QSize screenSize = graph->screen()->size(); container->setMinimumSize(QSize(screenSize.width() / 2, screenSize.height() / 1.6)); container->setMaximumSize(screenSize); container->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); container->setFocusPolicy(Qt::StrongFocus); - widget->setWindowTitle(QStringLiteral("Example of using axis range and selection")); - + //! [1] + QWidget *widget = new QWidget; + QHBoxLayout *hLayout = new QHBoxLayout(widget); + QVBoxLayout *vLayout = new QVBoxLayout(); hLayout->addWidget(container, 1); hLayout->addLayout(vLayout); + vLayout->setAlignment(Qt::AlignTop); + //! [1] + + widget->setWindowTitle(QStringLiteral("Surface example")); QGroupBox *modelGroupBox = new QGroupBox(QStringLiteral("Model")); |