//main.cpp
# define COIN_DLL
# define SOQT_NOT_DLL
# define SIMAGE_DLL
#include <QApplication>
#include "window.h"
int main(int argc, char *argv[])
{
Qt::Alignment topRight = Qt::AlignRight | Qt::AlignTop;
Window window;
window.show();
return app.exec();
}
//==============
//window.h
# define COIN_DLL
# define SOQT_NOT_DLL
# define SIMAGE_DLL
#ifndef WINDOW_H
#define WINDOW_H
#include <QWidget>
class CoinWidget;
{
Q_OBJECT
public:
Window();
private:
CoinWidget *coinWidget;
};
#endif
//==============
//window.cpp
# define COIN_DLL
# define SOQT_NOT_DLL
# define SIMAGE_DLL
#include <QtGui>
#include "coinwidget.h"
#include "window.h"
Window::Window()
{
coinWidget = new CoinWidget;
rootLayout->addWidget(coinWidget);
setLayout(rootLayout);
}
//==============
//coinwidget.h
# define COIN_DLL
# define SOQT_NOT_DLL
# define SIMAGE_DLL
#ifndef COINWIDGET_H
#define COINWIDGET_H
#include <QMainWindow>
#include <Inventor/Qt/SoQt.h>
//Forward declarations
class Model;
{
Q_OBJECT
public:
~CoinWidget();
QSize minimumSizeHint
() const;
protected:
Model *model;
};
#endif
//==============
//coinwidget.cpp
# define COIN_DLL
# define SOQT_NOT_DLL
# define SIMAGE_DLL
#include <QtGui>
#include <QtCore>
#include <Inventor/Qt/SoQt.h>
#include <Inventor/Qt/viewers/SoQtExaminerViewer.h>
#include "coinwidget.h"
#include "model.h"
{
SoQt::init(this);
model = new Model(this);
setCentralWidget(model->getWidget());
model->setDefaultScene();
}
CoinWidget::~CoinWidget() {
}
QSize CoinWidget
::minimumSizeHint() const { }
QSize CoinWidget
::sizeHint() const {
}
//==============
//model.h
# define COIN_DLL
# define SOQT_NOT_DLL
# define SIMAGE_DLL
#ifndef MODEL_H
#define MODEL_H
#include <Inventor/Qt/SoQt.h>
#include <Inventor/Qt/viewers/SoQtExaminerViewer.h>
#include <Inventor/nodes/SoBaseColor.h>
#include <Inventor/nodes/SoCone.h>
#include <Inventor/nodes/SoSeparator.h>
class Model : public SoQtExaminerViewer
{
public:
const char *name=NULL,
const SbBool embed=TRUE);
~Model(void);
void setDefaultScene();
private:
SoSeparator *root;
SoQtExaminerViewer * eviewer;
SoCone *cone;
SoBaseColor * col;
};
#endif
//==============
//model.cpp
# define COIN_DLL
# define SOQT_NOT_DLL
# define SIMAGE_DLL
#include <model.h>
const char * name,
const SbBool embed)
: SoQtExaminerViewer( parent,
name,
embed,
SoQtFullViewer::BUILD_ALL,
SoQtViewer::BROWSER, TRUE)
{
QWidget *widget
= this
->buildWidget
(this
->getParentWidget
());
this->setBaseWidget(widget); //comment this to see small 2nd viewer???
this->show();
}
// **************************
Model::~Model() {
delete this;
root->unref();
}
// **************************
void Model::setDefaultScene(void) {
root = new SoSeparator;
root->ref();
cone = new SoCone;
root->addChild(cone);
setSceneGraph(root);
}
//main.cpp
# define COIN_DLL
# define SOQT_NOT_DLL
# define SIMAGE_DLL
#include <QApplication>
#include "window.h"
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
Qt::Alignment topRight = Qt::AlignRight | Qt::AlignTop;
Window window;
window.show();
return app.exec();
}
//==============
//window.h
# define COIN_DLL
# define SOQT_NOT_DLL
# define SIMAGE_DLL
#ifndef WINDOW_H
#define WINDOW_H
#include <QWidget>
class CoinWidget;
class QHBoxLayout;
class Window : public QWidget
{
Q_OBJECT
public:
Window();
private:
QHBoxLayout *rootLayout;
CoinWidget *coinWidget;
};
#endif
//==============
//window.cpp
# define COIN_DLL
# define SOQT_NOT_DLL
# define SIMAGE_DLL
#include <QtGui>
#include "coinwidget.h"
#include "window.h"
Window::Window()
{
coinWidget = new CoinWidget;
rootLayout = new QHBoxLayout;
rootLayout->addWidget(coinWidget);
setLayout(rootLayout);
}
//==============
//coinwidget.h
# define COIN_DLL
# define SOQT_NOT_DLL
# define SIMAGE_DLL
#ifndef COINWIDGET_H
#define COINWIDGET_H
#include <QMainWindow>
#include <Inventor/Qt/SoQt.h>
//Forward declarations
class Model;
class CoinWidget : public QMainWindow
{
Q_OBJECT
public:
CoinWidget(QWidget *parent = 0);
~CoinWidget();
QSize minimumSizeHint() const;
QSize sizeHint() const;
protected:
Model *model;
};
#endif
//==============
//coinwidget.cpp
# define COIN_DLL
# define SOQT_NOT_DLL
# define SIMAGE_DLL
#include <QtGui>
#include <QtCore>
#include <Inventor/Qt/SoQt.h>
#include <Inventor/Qt/viewers/SoQtExaminerViewer.h>
#include "coinwidget.h"
#include "model.h"
CoinWidget::CoinWidget(QWidget *parent) : QMainWindow(parent)
{
SoQt::init(this);
model = new Model(this);
setCentralWidget(model->getWidget());
model->setDefaultScene();
}
CoinWidget::~CoinWidget() {
}
QSize CoinWidget::minimumSizeHint() const {
return QSize(200, 200);
}
QSize CoinWidget::sizeHint() const {
return QSize(400, 400);
}
//==============
//model.h
# define COIN_DLL
# define SOQT_NOT_DLL
# define SIMAGE_DLL
#ifndef MODEL_H
#define MODEL_H
#include <Inventor/Qt/SoQt.h>
#include <Inventor/Qt/viewers/SoQtExaminerViewer.h>
#include <Inventor/nodes/SoBaseColor.h>
#include <Inventor/nodes/SoCone.h>
#include <Inventor/nodes/SoSeparator.h>
class Model : public SoQtExaminerViewer
{
public:
Model( QWidget *parent = NULL,
const char *name=NULL,
const SbBool embed=TRUE);
~Model(void);
void setDefaultScene();
private:
SoSeparator *root;
SoQtExaminerViewer * eviewer;
SoCone *cone;
SoBaseColor * col;
};
#endif
//==============
//model.cpp
# define COIN_DLL
# define SOQT_NOT_DLL
# define SIMAGE_DLL
#include <model.h>
Model::Model( QWidget *parent,
const char * name,
const SbBool embed)
: SoQtExaminerViewer( parent,
name,
embed,
SoQtFullViewer::BUILD_ALL,
SoQtViewer::BROWSER, TRUE)
{
QWidget *widget = this->buildWidget(this->getParentWidget());
this->setBaseWidget(widget); //comment this to see small 2nd viewer???
this->show();
}
// **************************
Model::~Model() {
delete this;
root->unref();
}
// **************************
void Model::setDefaultScene(void) {
root = new SoSeparator;
root->ref();
cone = new SoCone;
root->addChild(cone);
setSceneGraph(root);
}
To copy to clipboard, switch view to plain text mode
Bookmarks