Bonjour,
je travaille avec QT et Coin3d (Inventor) sous linux et j'essaye de faire une application qui reuni les deux,et enfait je compile les deux en ligne de commande en utilsant g++
quand je compile ce code QT :
1 2 3 4 5 6 7 8 9
|
QApplication app(argc,argv);
QPushButton quit("Quit");
quit.resize(75,30);
quit.setFont(QFont("Times",18,QFont::Bold));
QObject :: connect(&quit,SIGNAL(cliked()),&app,SLOT(quit()));
quit.show();
return app.exec(); |
j'utilise la ligne de commande suivante :
g++ -g -o test -I /usr/lib64/qt4/include -L /usr/lib64/qt4/lib64 -lQtGui test.cc
et ca marche parfaitement,
quand je compile le code Coin suivant :
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
| #include <Inventor/SoDB.h>
#include <Inventor/Qt/SoQt.h>
#include <Inventor/Qt/editors/SoQtMaterialEditor.h>
#include <Inventor/Qt/SoQtRenderArea.h>
#include <Inventor/nodes/SoDirectionalLight.h>
#include <Inventor/nodes/SoMaterial.h>
#include <Inventor/nodes/SoPerspectiveCamera.h>
#include <Inventor/nodes/SoSeparator.h>
#include <Inventor/Qt/viewers/SoQtExaminerViewer.h>
main(int , char **argv)
{
// Initialize Inventor and Qt
QWidget *myWindow = SoQt::init(argv[0]);
// Build the render area in the applications main window
SoQtRenderArea *myRenderArea = new SoQtRenderArea(myWindow);
myRenderArea->setSize(SbVec2s(400, 200));
// Build the material editor in its own window
SoQtMaterialEditor *myEditor = new SoQtMaterialEditor;
// Create a scene graph
SoSeparator *root = new SoSeparator;
SoPerspectiveCamera *myCamera = new SoPerspectiveCamera;
SoMaterial *myMaterial = new SoMaterial;
root->ref();
myCamera->position.setValue(0.212482, 0.881014, 2.5);
myCamera->heightAngle = M_PI/4;
root->addChild(myCamera);
root->addChild(new SoDirectionalLight);
root->addChild(myMaterial);
// Read the geometry from a file and add to the scene
SoInput myInput;
if (!myInput.openFile("Barcelona.iv"))
exit (1);
SoSeparator *geomObject = SoDB::readAll(&myInput);
if (geomObject == NULL)
exit (1);
root->addChild(geomObject);
SoQtExaminerViewer * myViewer = new SoQtExaminerViewer(myWindow);
// Set the scene graph
myViewer->setSceneGraph(root);
// Attach material editor to the material
myEditor->attach(myMaterial);
// Show the application window and the material editor
myViewer->setTitle("Attach Editor");
myViewer->show();
SoQt::show(myWindow);
myEditor->show();
// Loop forever
SoQt::mainLoop();
} |
avec la ligne :
g++ -o test -I /usr/lib64/qt4/include/ -I /usr/lib64/qt4/include/Qt/ -I /usr/include/Coin2/ -L /usr/lib/Coin2/ test.cc -lCoin -lSoQt
ca marche aussi parfaitement..
mais j'essaye de combiner les deux :
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66
| #include <qapplication.h>
#include<qfont.h>
#include<qpushbutton.h>
#include <QtGui/QApplication>
#include<QtGui/QFont>
#include<QtGui/QPushButton>
#include<Inventor/SoDB.h>
#include <Inventor/Qt/SoQt.h>
#include <Inventor/Qt/editors/SoQtMaterialEditor.h>
#include <Inventor/Qt/SoQtRenderArea.h>
#include <Inventor/nodes/SoDirectionalLight.h>
#include <Inventor/nodes/SoMaterial.h>
#include <Inventor/nodes/SoPerspectiveCamera.h>
#include <Inventor/nodes/SoSeparator.h>
#include <Inventor/Qt/viewers/SoQtExaminerViewer.h>
main(int argc ,char **argd, char *argv[])
{
QApplication app(argc,argv);
QPushButton quit("Quit");
quit.resize(75,30);
quit.setFont(QFont("Times",18,QFont::Bold));
QObject :: connect(&quit,SIGNAL(cliked()),&app,SLOT(quit()));
quit.show();
return app.exec();
// Initialize Inventor and Qt
QWidget *myWindow = SoQt::init(argd[0]);
// Build the render area in the applications main window
SoQtRenderArea *myRenderArea = new SoQtRenderArea(myWindow);
myRenderArea->setSize(SbVec2s(400, 200));
// Build the material editor in its own window
SoQtMaterialEditor *myEditor = new SoQtMaterialEditor;
// Create a scene graph
SoSeparator *root = new SoSeparator;
SoPerspectiveCamera *myCamera = new SoPerspectiveCamera;
SoMaterial *myMaterial = new SoMaterial;
root->ref();
myCamera->position.setValue(0.212482, 0.881014, 2.5);
myCamera->heightAngle = M_PI/4;
root->addChild(myCamera);
root->addChild(new SoDirectionalLight);
root->addChild(myMaterial);
// Read the geometry from a file and add to the scene
SoInput myInput;
if (!myInput.openFile("Barcelona.iv"))
exit (1);
SoSeparator *geomObject = SoDB::readAll(&myInput);
if (geomObject == NULL)
exit (1);
root->addChild(geomObject);
SoQtExaminerViewer * myViewer = new SoQtExaminerViewer(myWindow);
// Set the scene graph
myViewer->setSceneGraph(root);
// Attach material editor to the material
myEditor->attach(myMaterial);
// Show the application window and the material editor
myViewer->setTitle("Attach Editor");
myViewer->show();
SoQt::show(myWindow);
myEditor->show();
// Loop forever
SoQt::mainLoop();
} |
avec la ligne :
g++ -o tes -I /usr/lib64/qt4/include/ -I /usr/lib64/qt4/include/Qt/ -I /usr/include/Coin2/ -L /usr/lib/Coin2/ -L /usr/lib64/qt4/lib64/ test.cc -lCoin -lSoQt -lQtGui
il me sort "incident de segmentation"
et j'ai essayé de cerner un peu le problem,il vient apparement de -lQtGui,mais je dois l'inculre sinon l'edition de liens ne se passera pas bien..
quelqu'un pourrait m'aider la dessus ?
Partager