View Full Version : show object (scene) in widget in class class mainwindow
rimie23
24th April 2012, 12:10
Hi,
it's me again
i create project qt+ogre i have not problem with that
for create this project i define class like that
class OgreWidget : public QWidget
{
Q_OBJECT
public:
OgreWidget(QWidget *parent = 0);
~OgreWidget();
.
.
.
and all my functions are in this class
for exemple
void OgreWidget::createScene()
void OgreWidget::setupNLoadResources()
void OgreWidget::paintEvent(QPaintEvent *e)
.
.
.
i change now my gui (interface) it's based now qmainwindows and the widget where i want create my scene there it's part of this class qmainwindows
i have now this
class MyInterface : public /*QWidget*/QMainWindow
{
Q_OBJECT
public:
QWidget *centralwidget;
. QMdiArea *mdiArea;
.
.
my interface mow is like that
7616
i want see my scene in the ceb$ntral widget "sous fenêtre" who it is on the mdiArea
is i must create another class ? how i do that ?
viulskiez
25th April 2012, 13:14
If you only need one scene, you can set your OgreWidget directly as the central widget in your QMainWindow instance by calling QMainWindow::setCentralWidget.
And if you need more than one scene, you can use QMdiArea, QMdiSubWindow and use QMdiArea::addSubWindow.
More example can be found on the Qt Reference Documentation.
rimie23
25th April 2012, 13:45
f you only need one scene, you can set your OgreWidget directly as the central widget in your QMainWindow instance by calling QMainWindow::setCentralWidget.
but my Ogrewidget is class
viulskiez
25th April 2012, 14:10
How many scene you want? One scene or more? If you need only one scene, don't inherit QMainWindow, keep subclassing QWidget, and set the central widget with your OgreWidget instance.
rimie23
25th April 2012, 14:44
thank you for repling
i want one scene
keep subclassing QWidget, and set the central widget with your OgreWidget instance.
it dos not work
i make the definition of my ogrewidget class in file
ogrewidget.h
class OgreWidget : public QWidget
{
Q_OBJECT
public:
OgreWidget(QWidget *parent = 0);
~OgreWidget();
protected:
//virtual void keyPressEvent(QKeyEvent *e);
// virtual void moveEvent(QMoveEvent *e);
void moveEvent ( QMoveEvent * e );
virtual void paintEvent(QPaintEvent *e);
virtual void showEvent(QShowEvent *e);
virtual void mousePressEvent(QMouseEvent *e/*vent*/);
virtual void Read_C3D_Data();
virtual void read_c3d();
//void add_camera(const Ogre::Vector3 &pos);
private:
void initOgreSystem();
void setupNLoadResources();
void createScene();
.
.
.
and i wrote the code of each function in ogrewidget.cpp
in another file interface.h i define my class mainwindow
class MyInterface : public QMainWindow
{
Q_OBJECT
public:
QWidget *centralwidget;
QDockWidget *dockWidget_2;
QWidget *dockWidgetContents_5;
QToolBox *toolBox_5;
QWidget *page_13;
QToolButton *toolButton_13;
QToolButton *toolButton_14;
QToolButton *toolButton_15;
QFrame *line;
QToolButton *toolButton_16;
QGroupBox *groupBox_8;
QDoubleSpinBox *doubleSpinBox_4;
QLabel *label_4;
QLabel *label_5;
QDoubleSpinBox *doubleSpinBox_5;
QDoubleSpinBox *doubleSpinBox_6;
QLabel *label_6;
QWidget *page_14;
QToolButton *toolButton_17;
QFrame *line_2;
QToolButton *toolButton_18;
QToolButton *toolButton_19;
QGroupBox *groupBox_6;
QDoubleSpinBox *doubleSpinBox;
QLabel *label;
QLabel *label_2;
QDoubleSpinBox *doubleSpinBox_2;
QDoubleSpinBox *doubleSpinBox_3;
QLabel *label_3;
QToolButton *toolButton_20;
QGroupBox *groupBox_7;
QWidget *page_15;
QMdiArea *mdiArea;
QWidget *subwindow
QStatusBar *statusbar;
QDockWidget *dockWidget_5;
QWidget *dockWidgetContents_8;
QListView *listView;
QScrollArea *scrollArea;
QWidget *scrollAreaWidgetContents;
MyInterface(QMainWindow* parent = 0);
};
in my file .cpp
MyInterface::MyInterface(QMainWindow *parent )
: QMainWindow (parent)
{
QWidget *centralwidget;
centralwidget = new QWidget(this);
centralwidget->setObjectName(QString::fromUtf8("centralwidget"));
setObjectName(QString::fromUtf8("MainWindow"));
resize(833, 411);
setCentralWidget(centralwidget);
setWindowTitle(QApplication::translate("MainWindow", "MainWindow", 0, QApplication::UnicodeUTF8));
page_13 = new QWidget();
page_13->setObjectName(QString::fromUtf8("page_13"));
page_13->setGeometry(QRect(0, 0, 98, 28));
.
.
.
.
this->setCentralWidget(new OgreWidget(this));
but dos not work
viulskiez
26th April 2012, 09:23
If this is the first time you use Ogre and Qt, I suggest you to read Lakin's Ogre-Qt (http://lakin.weckers.net/code/ogre3d/) first. I have successfully modified the source code 2 years ago. You can find interesting stuff about Qt and Ogre there..
rimie23
29th April 2012, 11:41
Hi , it's me
i make like that
class MainWindow : public QMainWindow
{
Q_OBJECT
public:
MainWindow()
:ogreWidget(0)
{
ogreWidget = new OgreWidget;
setCentralWidget(ogreWidget);
createDockWidget();
this->setObjectName(QString::fromUtf8("MainWindow"));
this->resize(833, 411);
this->setWindowTitle(QApplication::translate("MainWindow", "MainWindow", 0, QApplication::UnicodeUTF8));
}
but i yave problem , i saved it in vedeo to you see very well le problem it's not normal
http://www.4shared.com/video/vDLFIciu/err.html
Spitfire
1st May 2012, 12:51
If you want people to see your video, use website that doesn't require login to watch it.
rimie23
1st May 2012, 17:15
sorry , thanks for the advice
i have not the same problem now
but i still have problem
look at this picture
7660
you can see that the doclwidket is on my widget where i render my scene
i do not want that
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.