Results 1 to 9 of 9

Thread: show object (scene) in widget in class class mainwindow

  1. #1
    Join Date
    Apr 2012
    Posts
    101
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Windows

    Default show object (scene) in widget in class class mainwindow

    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
    Qt Code:
    1. class OgreWidget : public QWidget
    2. {
    3. Q_OBJECT
    4.  
    5. public:
    6. OgreWidget(QWidget *parent = 0);
    7. ~OgreWidget();
    8. .
    9. .
    10. .
    To copy to clipboard, switch view to plain text mode 
    and all my functions are in this class
    for exemple
    Qt Code:
    1. void OgreWidget::createScene()
    2. void OgreWidget::setupNLoadResources()
    3. void OgreWidget::paintEvent(QPaintEvent *e)
    4. .
    5. .
    6. .
    To copy to clipboard, switch view to plain text mode 
    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
    Qt Code:
    1. class MyInterface : public /*QWidget*/QMainWindow
    2. {
    3. Q_OBJECT
    4.  
    5. public:
    6. QWidget *centralwidget;
    7. . QMdiArea *mdiArea;
    8. .
    9. .
    To copy to clipboard, switch view to plain text mode 
    my interface mow is like that
    inter.jpg
    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 ?

  2. #2
    Join Date
    Jul 2010
    Location
    Indonesia
    Posts
    83
    Thanked 17 Times in 17 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Maemo/MeeGo

    Default Re: show object (scene) in widget in class class mainwindow

    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.
    ~ We are nothing in this universe ~

  3. #3
    Join Date
    Apr 2012
    Posts
    101
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: show object (scene) in widget in class class mainwindow

    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

  4. #4
    Join Date
    Jul 2010
    Location
    Indonesia
    Posts
    83
    Thanked 17 Times in 17 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Maemo/MeeGo

    Default Re: show object (scene) in widget in class class mainwindow

    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.
    Last edited by viulskiez; 25th April 2012 at 14:11. Reason: spelling corrections
    ~ We are nothing in this universe ~

  5. #5
    Join Date
    Apr 2012
    Posts
    101
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: show object (scene) in widget in class class mainwindow

    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
    Qt Code:
    1. class OgreWidget : public QWidget
    2. {
    3. Q_OBJECT
    4.  
    5. public:
    6. OgreWidget(QWidget *parent = 0);
    7. ~OgreWidget();
    8.  
    9.  
    10. protected:
    11. //virtual void keyPressEvent(QKeyEvent *e);
    12. // virtual void moveEvent(QMoveEvent *e);
    13. void moveEvent ( QMoveEvent * e );
    14. virtual void paintEvent(QPaintEvent *e);
    15. virtual void showEvent(QShowEvent *e);
    16.  
    17. virtual void mousePressEvent(QMouseEvent *e/*vent*/);
    18. virtual void Read_C3D_Data();
    19. virtual void read_c3d();
    20. //void add_camera(const Ogre::Vector3 &pos);
    21.  
    22.  
    23. private:
    24. void initOgreSystem();
    25. void setupNLoadResources();
    26. void createScene();
    27. .
    28. .
    29. .
    To copy to clipboard, switch view to plain text mode 
    and i wrote the code of each function in ogrewidget.cpp

    in another file interface.h i define my class mainwindow
    Qt Code:
    1. class MyInterface : public QMainWindow
    2. {
    3. Q_OBJECT
    4.  
    5. public:
    6. QWidget *centralwidget;
    7. QDockWidget *dockWidget_2;
    8. QWidget *dockWidgetContents_5;
    9. QToolBox *toolBox_5;
    10. QWidget *page_13;
    11. QToolButton *toolButton_13;
    12. QToolButton *toolButton_14;
    13. QToolButton *toolButton_15;
    14. QFrame *line;
    15. QToolButton *toolButton_16;
    16. QGroupBox *groupBox_8;
    17. QDoubleSpinBox *doubleSpinBox_4;
    18. QLabel *label_4;
    19. QLabel *label_5;
    20. QDoubleSpinBox *doubleSpinBox_5;
    21. QDoubleSpinBox *doubleSpinBox_6;
    22. QLabel *label_6;
    23. QWidget *page_14;
    24. QToolButton *toolButton_17;
    25. QFrame *line_2;
    26. QToolButton *toolButton_18;
    27. QToolButton *toolButton_19;
    28. QGroupBox *groupBox_6;
    29. QDoubleSpinBox *doubleSpinBox;
    30. QLabel *label;
    31. QLabel *label_2;
    32. QDoubleSpinBox *doubleSpinBox_2;
    33. QDoubleSpinBox *doubleSpinBox_3;
    34. QLabel *label_3;
    35. QToolButton *toolButton_20;
    36. QGroupBox *groupBox_7;
    37. QWidget *page_15;
    38. QMdiArea *mdiArea;
    39. QWidget *subwindow
    40. QStatusBar *statusbar;
    41. QDockWidget *dockWidget_5;
    42. QWidget *dockWidgetContents_8;
    43. QListView *listView;
    44. QScrollArea *scrollArea;
    45. QWidget *scrollAreaWidgetContents;
    46.  
    47. MyInterface(QMainWindow* parent = 0);
    48.  
    49. };
    To copy to clipboard, switch view to plain text mode 
    in my file .cpp
    Qt Code:
    1. MyInterface::MyInterface(QMainWindow *parent )
    2. : QMainWindow (parent)
    3.  
    4. {
    5.  
    6. QWidget *centralwidget;
    7.  
    8. centralwidget = new QWidget(this);
    9. centralwidget->setObjectName(QString::fromUtf8("centralwidget"));
    10.  
    11.  
    12. setObjectName(QString::fromUtf8("MainWindow"));
    13. resize(833, 411);
    14. setCentralWidget(centralwidget);
    15. setWindowTitle(QApplication::translate("MainWindow", "MainWindow", 0, QApplication::UnicodeUTF8));
    16.  
    17. page_13 = new QWidget();
    18. page_13->setObjectName(QString::fromUtf8("page_13"));
    19. page_13->setGeometry(QRect(0, 0, 98, 28));
    20.  
    21. .
    22. .
    23. .
    24. .
    25. [U]this->setCentralWidget(new OgreWidget(this));[/U]
    To copy to clipboard, switch view to plain text mode 
    but dos not work

  6. #6
    Join Date
    Jul 2010
    Location
    Indonesia
    Posts
    83
    Thanked 17 Times in 17 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Maemo/MeeGo

    Default Re: show object (scene) in widget in class class mainwindow

    If this is the first time you use Ogre and Qt, I suggest you to read Lakin's Ogre-Qt first. I have successfully modified the source code 2 years ago. You can find interesting stuff about Qt and Ogre there..
    ~ We are nothing in this universe ~

  7. #7
    Join Date
    Apr 2012
    Posts
    101
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: show object (scene) in widget in class class mainwindow

    Hi , it's me
    i make like that
    Qt Code:
    1. class MainWindow : public QMainWindow
    2. {
    3. Q_OBJECT
    4.  
    5. public:
    6. MainWindow()
    7. :ogreWidget(0)
    8. {
    9. ogreWidget = new OgreWidget;
    10. setCentralWidget(ogreWidget);
    11.  
    12. createDockWidget();
    13.  
    14.  
    15. this->setObjectName(QString::fromUtf8("MainWindow"));
    16. this->resize(833, 411);
    17. this->setWindowTitle(QApplication::translate("MainWindow", "MainWindow", 0, QApplication::UnicodeUTF8));
    18.  
    19. }
    To copy to clipboard, switch view to plain text mode 
    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

  8. #8
    Join Date
    Sep 2011
    Location
    Manchester
    Posts
    538
    Thanks
    3
    Thanked 106 Times in 103 Posts
    Qt products
    Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: show object (scene) in widget in class class mainwindow

    If you want people to see your video, use website that doesn't require login to watch it.

  9. #9
    Join Date
    Apr 2012
    Posts
    101
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: show object (scene) in widget in class class mainwindow

    sorry , thanks for the advice
    i have not the same problem now
    but i still have problem
    look at this picture
    err1.jpg
    you can see that the doclwidket is on my widget where i render my scene
    i do not want that

Similar Threads

  1. Replies: 4
    Last Post: 23rd August 2011, 22:53
  2. Replies: 7
    Last Post: 18th August 2011, 15:43
  3. Replies: 6
    Last Post: 20th July 2009, 17:35
  4. Accessing a class Object by pointer in another class
    By pdoria in forum Qt Programming
    Replies: 2
    Last Post: 14th January 2008, 16:59
  5. Replies: 3
    Last Post: 16th May 2007, 12:07

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.