PDA

View Full Version : Coin3d + Qt: SIGLNALs and SLOTs



vonCZ
7th May 2007, 13:17
In my attempts last week to render a Coin3d scene in a Qt application, I used Qt's hellogl demo program as a template and modified it. The Coin scene renders nicely now, but I cannot get it to recognize Qt's signals & slots. My window.cpp file still contains this:


connect(xSlider, SIGNAL(valueChanged(int)), coinWidget, SLOT(setXRotation(int)));
connect(coinWidget, SIGNAL(xRotationChanged(int)), xSlider, SLOT(setValue(int)));

My CoinWidget constructor looks like this:


CoinWidget::CoinWidget(QWidget *parent) : QMainWindow(parent)
{
SoQt::init(this);

SoSeparator *root = new SoSeparator;
SoRotationXYZ *rootRot = new SoRotationXYZ;
root->ref();

root->addChild(rootRot);
root->addChild(new SoCone);

rootRot->angle=xRot;

SoQtExaminerViewer *eviewer = new SoQtExaminerViewer(this);
eviewer->setDecoration(false);
eviewer->setSceneGraph(root);
eviewer->show();

}

...such that the xRot variable *should* be modified by moving the slider (and thus cause my model to rotate), but it's not happening. I'm thinking that when using SoQt, there may be an additional step involved. Any suggestions?

marcel
7th May 2007, 13:40
Does connect outputs any warnings/errors?

wysota
7th May 2007, 13:53
Did you remember about adding Q_OBJECT macro to your class header?

vonCZ
7th May 2007, 14:11
yes, I've included the Q_OBJECT macro. Marcel, no errors that I know of, but I wouldn't expect any: the signal/slot code and functions are lifted straight from the HelloGL demo, so I think everything is working fine there. I'll add a QLCDNumber widget now, just to make sure the xRot value is changing when I move the slider. (although I put a temporary exit() statement in the setXRotation() function just to make sure it was being called, and it was.)

marcel
7th May 2007, 15:00
Trey using qDebug in the suspect slots to see if they are called. You should open your app from the console in this case.

pdolbey
7th May 2007, 18:51
What are setRotationX/Y/Z actually doing?

Pete

vonCZ
8th May 2007, 11:34
Thanks for the tip, Marcel: i hadn't used qDebug before; very useful. As it turns out, the function was being called but the values weren't updating properly. That's fixed now, but it's still not working, but at least now I know the problem is on the Coin3d side, which I think I've almost got worked out.

Pete- the model in my Coin3d scene should rotate around the X, Y, or Z axis when setRotationX/Y/Z are called.

pdolbey
8th May 2007, 17:08
As a techie I was sort of expecting a code listing - but from your answer, I could see you having a great future in "requirements":D

Have you sorted it yet?

Pete

vonCZ
9th May 2007, 16:11
No, I've not sorted it yet.:(

I've learned that I need to add a Coin3d field, SoSFFloat, to my program, and use this (rather than a standard float) to update the rotation value. Here's the code-

coinwidget.h

#ifndef COINWIDGET_H
#define COINWIDGET_H

#include <QMainWindow>

#include <Inventor/Qt/SoQt.h>
#include <Inventor/nodes/SoSeparator.h>
#include <Inventor/nodes/SoRotationXYZ.h>
#include <Inventor/nodes/SoCone.h>
#include <Inventor/Qt/viewers/SoQtExaminerViewer.h>
#include <Inventor/fields/SoSFFloat.h>

class CoinWidget : public QMainWindow
{
Q_OBJECT

public:
CoinWidget(QWidget *parent = 0);
~CoinWidget();

QSize minimumSizeHint() const;
QSize sizeHint() const;

float deg2rad(int angle) { return (angle * 3.1416/180.00); }

// SoSFFloat xRot;

public slots:
void setXRotation(int angle);
void setYRotation(int angle);
void setZRotation(int angle);

signals:
void xRotationChanged(int angle);
void yRotationChanged(int angle);
void zRotationChanged(int angle);

protected:

private:
void normalizeAngle(int *angle);

};

#endif

coinwidget.cpp


#include <QtGui>
#include <Inventor/Qt/SoQt.h>
#include <Inventor/nodes/SoSeparator.h>
#include <Inventor/nodes/SoRotationXYZ.h>
#include <Inventor/nodes/SoCone.h>
#include <Inventor/Qt/viewers/SoQtExaminerViewer.h>
#include <Inventor/fields/SoSFFloat.h>

#include <math.h>

#include "coinwidget.h"

CoinWidget::CoinWidget(QWidget *parent) : QMainWindow(parent)
{

SoQt::init(this);

SoSeparator *root = new SoSeparator;
SoRotationXYZ *rootRot = new SoRotationXYZ;

// rootRot->angle=xRot.getValue();
root->ref();

root->addChild(rootRot);
root->addChild(new SoCone);

SoQtExaminerViewer *eviewer = new SoQtExaminerViewer(this);
eviewer->setDecoration(false);
eviewer->setSceneGraph(root);
eviewer->show();

}

CoinWidget::~CoinWidget()
{
}

QSize CoinWidget::minimumSizeHint() const {
return QSize(200, 200);
}

QSize CoinWidget::sizeHint() const {
return QSize(400, 400);
}

void CoinWidget::setXRotation(int angle)
{
float a = deg2rad(angle);
qDebug("angle = %.4f\n", a);

/*
if(a != rootRot->angle.getValue()) {
rootRot->angle=a;
}
*/
}

void CoinWidget::setYRotation(int angle) {
}

void CoinWidget::setZRotation(int angle) {
}

you can ignore the setXRotation() function for now. My problem is: if I simply uncomment the "SoSFFloat xRot;" statement in the class declaration, my program will compile/link but I get a "Microsoft Visual C++ Runtime Library" dialog-box error message:


Assertion failed!

Program c:\qt_tutorial\testprog.exe
File: c:\orig_coindir\source\Coin-2.4.6\src\fields\sosffloat.cpp
Line: 49
Expression: SoSFFloat::classTypeId != SoType::badType()

If I declare the same variable within the CoinWidget constructor, however, it runs fine... the problem here, though, is that I cannot then access the variable from other member functions, notably setXRotation().

I should mention/say: the file
File: c:\orig_coindir\source\Coin-2.4.6\src\fields\sosffloat.cpp doesn't actually exist. This was the location of my initial Coin3d installation, which has since been deleted. In my Visual Studio project, in the "vsvar32.txt" file, and in my system Environment Variables: this directory doesn't exist! ...so I don't know why it's referring to it here. Anyway, I don't think this is related to my problem, since I only seem to have a problem with the SoSFFloat variable when I declare it in the Class Declaration and not in the constructor.

Any ideas? Anyone? Buehler?

marcel
9th May 2007, 20:44
Leave xRot a member but try to initialize it somehow( I don't know what ways of initialization are there - but I am sure there is at least one ) in the constructor.

It seems this is the problem, you use xRot uninitialized.

Regards

pdolbey
9th May 2007, 20:45
You've got one or 2 gotchas in that code. I'm still trying to understand Coin3d myself but there's a few fundamental problems with your code.

The first problem is that the root of your scenegraph and the rotation node is orphaned once you've left the scope of the CoinWidget constructor. That should be an easy fix - move their pointers into the header file i.e. define (I now tend to use my.. as a member prefix)


protected:
SoSeparator *myRoot;
SoRotationXYZ *myRootRot;


and change the constructor to


.
myRoot = new SoSeparator;
myRootRot = new SoRotationXYZ;
.

Now you've got initialised objects available throughout your class. You should add a


delete myRoot;
delete myRootRot;

in the destructor. The next problem seems to be that you have never initialised the xRot variable. I think you can change the definition of xRot in the header to


float xRot;

Now in the constructor change the code to


.
myRootRot = new SoRotationXYZ;
xRot = 0.0f
myRootRot->angle.setValue(xRot);
myRoot->ref();
myRoot->addChild(rootRot);
myRoot->addChild(new SoCone);
.

Thex setXRotation has something like


if(a != xRot)
{
xRot = a;
myRootRot->angle.setValue(xRot);
}

The assert is likely to have been displayed because the SosFFloat was never initialised with a setValue - and I guess your still linking to a debug libary that has an internal reference to the original source code that you've now deleted. You might want to consider using an "SoRotation" instead later when you try to combine the other axes.

Hope this helps

Pete

vonCZ
11th May 2007, 11:08
Thanks Pete/Marcel for the suggestions. Pete: you mentioned "move their pointers into the header file." Good idea, except I couldn't do this before because I needed to state


SoQt::init(this);

before I could refer to any of the Coin classes (SoRotationXYZ, SoSFFloat, etc). But the SoQt::init() is in the CoinWidget constructor, so I couldn't refer to SoSFFloat in the coinwidget.h file. I've gotten around this now by creating a separate class, "Model," to hold all of my Coin geometry. These are my files:

main.cpp
window.h/.cpp (the Qt interface)
coinwidget.h/.cpp (the Coin3d initialization)
model.h/.cpp (the Coin3d geometry)

My problem now, however: I declare a "coinWidget" object in my Window class, and then a "model" object in my "CoinWidget" class... but now I don't know how I can send signals from my Qt objects (i.e. "xSlider") to my "model" signals. (I haven't defined the signal/slot functions in my Model class yet; they're still in the CoinWidget class. I wanted to see if it's possible, first.)

Should I, for example, go ahead and pass the signals from Window to CoinWidget as I'm doing now, then emit the signal again from CoinWidget to the Model class (after I set up the slots in the Model class, of course)?

I apologize in advance: i'm going to post the program files, below. If it's innappropriate for me to do so, let me know Wysota.;)


++++++ main.cpp ++++++
#include <QApplication>

#include "window.h"

int main(int argc, char *argv[])
{
QApplication app(argc, argv);
Window window;
window.show();
return app.exec();
}

++++++ window.h ++++++
#ifndef WINDOW_H
#define WINDOW_H

#include <QWidget>

class CoinWidget;
class QSlider;

class Window : public QWidget
{
Q_OBJECT

public:
Window();

private:

QSlider *createSlider();

CoinWidget *coinWidget;
QSlider *xSlider;

};

#endif

++++++ window.cpp ++++++
#include <QtGui>

#include "coinwidget.h"
#include "window.h"

Window::Window()
{
coinWidget = new CoinWidget;

xSlider = createSlider();

connect(xSlider, SIGNAL(valueChanged(int)), coinWidget, SLOT(setXRotation(int)));
connect(coinWidget, SIGNAL(xRotationChanged(int)), xSlider, SLOT(setValue(int)));

// NOTE: above is how I did it when I thought I could place the model in
// the CoinWidget class. Now that I've a separate class, Model,
// which contains the model, I don't know how I can pass SIGNALs to
// a Model object without declaring the object here first... but which
// doesn't make sense to do. I declare the "model" object in the
// Coinwidget::Coinwidget() constructor. ...although, as I asked above:
// perhaps I should leave this as it is, then forward the signal on to the
// model class?

QHBoxLayout *mainLayout = new QHBoxLayout;
mainLayout->addWidget(coinWidget);
mainLayout->addWidget(xSlider);
setLayout(mainLayout);

xSlider->setValue(12);
setWindowTitle(tr("Hello COIN"));
}

QSlider *Window::createSlider()
{
QSlider *slider = new QSlider(Qt::Vertical);
slider->setRange(0, 360);
slider->setSingleStep(36);
slider->setPageStep(12);
slider->setTickInterval(12);
slider->setTickPosition(QSlider::TicksRight);
return slider;
}

++++++ coinwidget.h ++++++
#ifndef COINWIDGET_H
#define COINWIDGET_H

#include <QMainWindow>
#include <Inventor/Qt/SoQt.h>

class CoinWidget : public QMainWindow
{
Q_OBJECT

public:
CoinWidget(QWidget *parent = 0);
~CoinWidget();

QSize minimumSizeHint() const;
QSize sizeHint() const;

float deg2rad(int angle) { return (angle * 3.1416/180.00); }

public slots:

// refer to other comments
void setXRotation(int angle);

signals:

// refer to other comments
void xRotationChanged(int angle);

protected:


private:
void normalizeAngle(int *angle);

};

#endif

++++++ coinwidget.cpp ++++++
#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 *model = new Model(this);

setCentralWidget(model->getWidget());
model->setDefaultScene();

}

CoinWidget::~CoinWidget() {

// delete model; // : error C2065: 'model' : undeclared identifier
// So I added "delete this;" in Model::~Model();
// Is this the proper way to delete pointer/allocated memory
// to the "model" object?

}

QSize CoinWidget::minimumSizeHint() const {

return QSize(200, 200);

}

QSize CoinWidget::sizeHint() const {

return QSize(400, 400);

}

void CoinWidget::setXRotation(int angle)
{

// I was thinking that I should delete this member function, since this Class is set up
// only to initialize the Coin3d window... but--again, as I asked above--maybe I should
// keep it, and pass the signal again to the Model class. I realize, btw, that the
// function doesn't do anything currently. I'll sort that out after I figure out how to
// route the signals/slots.

float a = deg2rad(angle);
qDebug("angle = %.4f", a);
}

++++++ model.h ++++++
#ifndef MODEL_H
#define MODEL_H

#include <Inventor/Qt/SoQt.h>
#include <Inventor/Qt/viewers/SoQtExaminerViewer.h>
#include <Inventor/nodes/SoSeparator.h>
#include <Inventor/nodes/SoRotationXYZ.h>
#include <Inventor/fields/SoSFFloat.h>

class Model : public SoQtExaminerViewer
{

public:

Model( QWidget *parent = NULL, const char *name=NULL, const SbBool embed=TRUE);
~Model(void);

void setDefaultScene();

protected:

private:

SoSeparator *root;
SoRotationXYZ *myRot;
SoSFFloat xRot;

};

#endif

++++++ model.cpp ++++++
#include <Inventor/Qt/SoQt.h>
#include <Inventor/nodes/SoSeparator.h>
#include <Inventor/nodes/SoRotationXYZ.h>
#include <Inventor/nodes/SoCone.h>
#include <Inventor/Qt/viewers/SoQtExaminerViewer.h>
//#include <Inventor/fields/SoSFFloat.h>


#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);
this->setDecoration(false);
}


Model::~Model() {

delete this;

/* FYI Pete:
"You can not call delete on nodes [including SoSeparators, SoRotationXYZ, etc.]
because the destructor is protected. Nodes are deleted when you call unref() on
them and the reference count goes to zero. You must of course first ref() a node
before you can unref() it." from a Coin3d developer
*/
root->unref();
myRot->unref(); //actually, I guess I shouldn't do this since I didn't "ref()" it.

}

void Model::setDefaultScene(void) {

root = new SoSeparator;
root->ref();
root->addChild(new SoCone);

this->setSceneGraph(root);
this->show();

}

vonCZ
11th May 2007, 13:46
In case a simple visual will help, here it is. Again, the problem is I don't know how to connect the SIGNAL from the slider, to the cone rotation.

marcel
11th May 2007, 14:00
I didn't look at the code yet, but the normal approach is to create wrappers in the classes that are liked to the signal and slot you want to connect.

For example if class A contains object obj1 and class B contains object obj2, then to connect a signal from obj1 to a slot in obj2:
obj1 signal -> class A slot -> class A signal -> class B slot -> obj2 slot.

Of course, this has to be done from a class that hass access to both A and B.
This you can do if you don't want to redesign too much.

Regards

vonCZ
11th May 2007, 14:28
First I should say: it is no problem at all to do a complete redesign. I think there is a simple solution, on how to connect a Qt widget to Coin geometry/fields/etc, I just don't know how to do it yet. (I think I said this before: Qt is awesome, with all the sample code to figure out how to do things. Coin on the other hand: almost nothing, not even a simple demo to integrate Coin & Qt.)

Do I understand you correctly: by "wrapper", do you mean create a new class that derives from both the Window and Model classes (the Qt widget and Coin geometry classes), and use functions from this class to access the Model fields? For example:

given:
qt _obj
model_obj

qt_obj signal -> WrapperClass slot -> function in WrapperClass updates field_value in model_obj (i.e. SoSFFloat xRot)

marcel
11th May 2007, 14:32
No, I said "wrapper functions" - signals and slots.

vonCZ
11th May 2007, 18:35
OK, Marcel, from what I gather you're talking standard SIGNALs and SLOTs stuff, right? So I need to be able to add SLOTs in my Model class.

but: my Model class (in "model.cpp") doesn't (and cannot?) have any SLOTs, because it derives only from a Coin3d class, "SoQtExaminerViewer". I want to put fields/variables in my Model class that are updated by input from Window-class SIGNALs. What is the best way to add them?? I must include the Q_OBJECT macro and, presumably, derive my Model class not only from the SoQtExaminerViewer class, but also from a Qt class. Which class should I choose? ...or is this even the right path?

jacek
11th May 2007, 20:09
I've posted this in the Newbie section without much luck yet; figured I'd try here.
Please, don't post multiple threads on the same topic.


but: my Model class (in "model.cpp") doesn't (and cannot?) have any SLOTs, because it derives only from a Coin3d class, "SoQtExaminerViewer".
Then use multiple inheritance. Just note that, due moc limitations, QObject must be listed as the first super class.

vonCZ
12th May 2007, 07:23
Please, don't post multiple threads on the same topic.

plz delete #18 above; it's confusing here twice.

pdolbey
12th May 2007, 17:09
Here's a bit of a hackaround with your code.

I've used the old setXRotation in the coinwidget as a wrapper for the model (now promoted to be a class member). Model now its own setXRotation(float angle), but this is just a standard method available to the proxy. The order of adding children to the root is important - think left to right - so


root->addChild(myRot);
root->addChild(new SoCone);

works but


root->addChild(new SoCone);
root->addChild(myRot);

appears not to as the cone is now left of the rotation. Anyway the attached zip file was working for me. But remember that this technique is rotating the objects in "world space" - not just rotating the camera postion around the scene.

Pete

vonCZ
12th May 2007, 19:02
I've used the old setXRotation in the coinwidget as a wrapper for the model (now promoted to be a class member).

BEAUTIFUL!! Thanks a million, Pete!

X-man
21st May 2007, 04:22
Following the very useful examples, and after having hours of conversation with vonCZ, I managed to use the proposed solutions for my -similar- project... Now, here's my problem.

***Please note that I am absolutely new to Qt, Coin, and C++, so probably the answer might be something really obvious, but not to me!***

So, I managed to have window.h/window.cpp, model.h/model.cpp, and coinwidget.h/coinwidget.cpp working. What I am trying to do now, is have one more window with the coin screen. Here's why; I want to have the (initial) window with some control features i added (couple of spinboxes etc) and the second window (which I create with window2.h/window2.cpp) to have the coin model and a couple of widgets. BUT, with what I've written I get two instances of coinwidget, therefore all my signals from window.cpp spinboxes do not have any effect to my window2 coin model. To make it more clear: I need to use the window.cpp coinwidget instance in my window2.cpp.

I am certain the answer is clear to someone with OOP experience, I do suspect that it has something to do with declaring public classes and instances, but still don't know how to get around....

Here's a bit of my code (I shouldn't post the whole thing since it's going to be long)...

main.cpp

the same as in the previous post, only changes are:

Window *window = new Window();
Window2 *window2 = new Window2();
window->show();
window2->show();

window.h

Only change is transferring "CoinWidget *coinWidget;" from the private: to the public:

window2.h

#ifndef WINDOW2_H
#define WINDOW2_H

#include <QWidget>
#include "window.h"
class CoinWidget;
class QSlider;
class QDial;

class Window2 : public QWidget
{
Q_OBJECT

public:
Window2();

public slots:

private:

QSlider *xSlider;
QDial *J2Dial;
};
#endif

window2.cpp

#include <QtGui>
#include "coinwidget.h"
#include "window2.h"
#include "window.h"

Window2::Window2()
{
xSlider = new QSlider;
J2Dial = new QDial;
QGridLayout *mainLayout2 = new QGridLayout;
//mainLayout2->addWidget(coinWidget); <-- This is the part not working
mainLayout2->addWidget(xSlider);
setLayout(mainLayout2);
xSlider->setValue(0);
xSlider->setRange(0,360);
J2Dial->setRange(-125,125);
J2Dial->setNotchesVisible(1);
J2Dial->setNotchTarget(5.0);
J2Dial->setSingleStep(1.0);
}

No changes were made to model.h, model.cpp, coinwidget.h, coinwidget.cpp (ok, there are changes but are not related to the problem-honestly!).

Any help will be greatly appreciated, thanks in advance.

X-man

PS. Sorry for the long post!

pdolbey
21st May 2007, 18:44
X-man,

I did see your post earlier, but my first reply got scewed up by a timeout.

Its not too hard to get references from one window to another. However what I think your trying to do is display the same widget in two containers - and I don't really think thats very sensible. In the windows world your widget will eventually map to a HWND which is unique to a window.

My original mods for vonCZ were based on making his existing code work with as small changes as possible. Theres are a number of considerations.

1. The Model class manages both a Coin viewer and its scenegraph - this should really have been split into 2 separate classes.
2. The coinwidget interacts with a rotation node in the scenegraph. This effectively changes the rotation of the code in world space, not the position of the camera.

I'd like to get a better understanding of what your tying to achieve, perhaps some screen mock-ups, before making any further suggestions. I would still always ask the core question as well - "Why are you trying to do it this way?".

Pete

X-man
22nd May 2007, 03:50
Pete,

first of all, thanks for the reply. Now, regarding your points...

1. It make sense; i mean, having them in separate classes - but that should not be a problem for the time being (or is it? if so, any advice on how to change that->creating two classes?)
2. No problem with that - I now have six (6) spinboxes inside my window.cpp, who alter six rotation nodes inside my model. As for them rotating in real world (not camera), that's exactly what I want them to do.

Ok, now on to your "why-are-you-doing-that" question...

From what I understood in your example (correct me if I'm wrong), the application shows a window (created in window.cpp), which includes some widgets (a slider in your case, some spinboxes in mine), one of the widgets being coinwidget, which then (through the coinwidget.cpp) creates a -coin- model, which is also shown (since we have a "show();" near the end of model.cpp).

Where I want to get - one window with my spinboxes alone, which communicate via slots/signals with certain rotation nodes of the model (via the coinwidget), in order to rotate my model. And then, another window with that model and ALSO a couple of Qt widgets (I'm not sure yet what kind of widgets I will be needing, but lets take for example that I will need some QLCDNumber widgets).

And here's the problem; in order to connect the spinboxes in window.cpp (the same way you connected the slider), I create a coinwidget = new coinwidget. Just in order to do the slot/signal thing (let's say that I don't even include the "mainLayout->addWidget (coinWidget);" part). So, at that point we have a coinwidget created, with certain rotations altered "dynamically" from some widgets inside the window.cpp, and all these changes can be seen in the created model (because of the "show()" in model.cpp). Now, if I want in my window2.cpp to have that same model shown at (0,0) and have my other widgets (the lcdnumbers) underneath, I don't know how to call that instance. Naturally, if I just go with "addWidget (coinWidget);", it returns that it is undeclared, if I have a "coinwidget2 = new Coinwidget" before, I get a model shown, but it's just a new instance, so any changes I make in my spinboxes, are not trasmitted inside this model. I also tried something like "addWidget (Window::coinWidget)", but I got "illegal reference to non-static member 'Window::coinWidget'" in return.

Am I going the wrong way here? I'm open to any suggestions, either in terms of general approach or in specific coding instructions.

Let me know if you need the whole of my code to check it out - i'll .rar it and pass it on.

Thanks again for your attention, I appreciate it :) .

X-man

pdolbey
22nd May 2007, 09:18
X-man,

Sorry but I'm at work athe moment so I can't give you a "tested" response, but I can give you something to work on during the day. I can break your problem into two peices

1. How do I connect the signals and slots.
2. How do I share a scenegraph.

The first is relatively straightforward - I'll outline 3 options, but for now I'd recommend the first as it should be the easiest to implement and test.

a) Alter your Window2 constructor to take a Window pointer, and cache it in a Window2 member variable - perhaps call it "partnerWindow". From the top down in main.cpp you'd see something like


Window *window = new Window();
Window2 *window2 = new Window2(window);
window->show();
window2->show();

Now you can connect public slots and signals between the two windows in your Window2 constructor - or another method.

b) Connect the signals and slots statically in main.cpp with fully qualified QObject::connect(.....) methods - you have pointers to both objects here.

c) Build a new proxy "controller" class and use this to sychronise events between the 2 windows.

The next piece needs some testing, but in essence what you can do is to expose the scenegraph root node in window.cpp/h via a public getSceneGraph() function. In option a) this can be accessed directly from the new classmember (partnerWindow) - in options c) and b) you might need a corresponding setSceneGraph(...) exposed in Window2. Both set/getSceneGraph will actually need to be wrappers for the enclosed Model objects which will also need amending . Now you should be able to set the Window's Model scenegraph as the root node of the Model in Window2 - what happens next I can't tell. I'll try it myself tonight.

You can post the code to "peter at dolbey dot freeserve dot co dot uk" - with the usual replacements.

Pete

jwieland
23rd February 2009, 19:03
Hi pdolbey,

I am trying to learn how to embed a coin widget inside a qt display and found your post very helpful. Could you post your .ui file so that I can open and manipulate inside qt designer?

Thanks a lot.

J. Wieland

vonCZ
15th May 2009, 07:34
I don't use Designer, so don't follow the threads too closely on how to integrate Coin and Qt on designer (i'm refering to the threads on the Coin list; there aren't any here, far as I can tell.)


But my understanding is: You cannot use SoQtExaminerViewer (or the other SoQt viewer/renderArea classes) with Designer, and therefore pDolbey or anyone else with a Coin3d+SoQt* project won't have a .ui file. On the other hand: Coin3d came out with Quarter recently, which does enable you to use Designer to build your Qt/Coin3d apps. But again: I haven't used this (Quarter), either. Nevertheless: "quarter" is what you're looking for if you want to build your apps with Designer. I think.:o