Results 1 to 11 of 11

Thread: update the view dynamically

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

    Default update the view dynamically

    Hi, i returned with new problem
    as you know i have like that
    in the main i make
    Qt Code:
    1. #include <QApplication>
    2. #include "my_interface.h"
    3. int main(int argc, char **argv)
    4. {
    5. QApplication app(argc, argv);
    6. MainWindow window;
    7. window.show();
    8. window.setViewNum(1);//or window.setViewNum(4);
    9.  
    10. return app.exec();
    11. }
    To copy to clipboard, switch view to plain text mode 
    in mainwindow.h i make like that
    Qt Code:
    1. class MainWindow : public QMainWindow
    2. {
    3. Q_OBJECT
    4. public:
    5. MainWindow();
    6. void setViewNum(int num);
    To copy to clipboard, switch view to plain text mode 
    and in the .cpp
    Qt Code:
    1. MainWindow::MainWindow()
    2. {
    3.  
    4. mQOgreWidget = new QOgreWidget(this);
    5.  
    6. setCentralWidget(mQOgreWidget);
    7.  
    8. if(mQOgreWidget->isVisible())
    9. mQOgreWidget->setViewNum(1);//or mQOgreWidget->setViewNum(4);
    10.  
    11. }
    To copy to clipboard, switch view to plain text mode 
    and in QOgreWidget.h
    Qt Code:
    1. public slots :
    2. void setViewNum(int num);
    3. void setCameraPosition(const Ogre::Vector3 &pos);
    To copy to clipboard, switch view to plain text mode 
    in QOgreWidget.cpp
    Qt Code:
    1. void QOgreWidget::setViewNum(int num)
    2. {
    3. if(num == 1)
    4. {
    5.  
    6. QWidget *central0 = new QGroupBox("My Scene", this);
    7. float wi0=central0->width();
    8. float hi0=central0->height();
    9.  
    10. QOgreRenderWindow * orw0 = new QOgreRenderWindow(QString("View2"),mSceneMgr,mRoot,nb_cam,wi0,hi0);
    11.  
    12. QHBoxLayout* Layout0 = new QHBoxLayout();
    13. Layout0->addWidget(orw0);
    14.  
    15. central0->setLayout(Layout0);
    16.  
    17.  
    18. mVerticalLayout->addWidget(central0);
    19.  
    20. }
    21. if(num == 4)
    22. {
    23.  
    24. QHBoxLayout* mainlayout = new QHBoxLayout();
    25.  
    26. QGridLayout* rightSide = new QGridLayout;
    27. /////////////////////////////////////////////////////////////////////////////////////////
    28. QWidget *central = new QGroupBox("My Scene", this);
    29. //QLabel* orw = new QLabel("i am",central);
    30. float wi=central->width();
    31. float hi=central->height();
    32. QOgreRenderWindow *orw = new QOgreRenderWindow(QString("View0"),mSceneMgr,mRoot,nb_cam,wi,hi);
    33. mQOgreRenderWindowList.append(orw);
    34. mainlayout->addWidget(orw);
    35. central->setLayout(mainlayout);
    36. /////////////////////////
    37. QWidget *central1 = new QGroupBox("0,0", this);
    38. float wi1=central1->width();
    39. float hi1=central1->height();
    40. QOgreRenderWindow * orw1 = new QOgreRenderWindow(QString("View1"),mSceneMgr,mRoot,nb_cam,wi1,hi1);
    41. mQOgreRenderWindowList.append(orw1);
    42.  
    43.  
    44. QHBoxLayout* Layout1 = new QHBoxLayout();
    45. Layout1->addWidget(orw1);
    46. central1->setLayout(Layout1);
    47. /****************************/
    48. QWidget *central2 = new QGroupBox("0,1", this);
    49. wi=central2->width();
    50. hi=central2->height();
    51.  
    52. QOgreRenderWindow *orw2 = new QOgreRenderWindow(QString("View2"),mSceneMgr,mRoot,nb_cam,wi,hi);
    53. mQOgreRenderWindowList.append(orw2);
    54. QHBoxLayout* Layout2 = new QHBoxLayout();
    55. Layout2->addWidget(orw2);
    56. central2->setLayout(Layout2);
    57.  
    58.  
    59.  
    60. ////////////////////////////////////////////////////////////////////*
    61. QWidget *central3 = new QGroupBox("0,2", this);
    62. wi=central3->width();
    63. hi=central3->height();
    64.  
    65. QOgreRenderWindow * orw3 = new QOgreRenderWindow(QString("View3"),mSceneMgr,mRoot,nb_cam,wi,hi);
    66. mQOgreRenderWindowList.append(orw3);
    67. QHBoxLayout* Layout3 = new QHBoxLayout();
    68. Layout3->addWidget(orw3);
    69. central3->setLayout(Layout3);
    70. /////////////////////////////////////////////////////////
    71. QWidget *central4 = new QGroupBox("1,0", this);
    72. wi=central4->width();
    73. hi=central4->height();
    74.  
    75. QOgreRenderWindow *orw4 = new QOgreRenderWindow(QString("View4"),mSceneMgr,mRoot,nb_cam,wi,hi);
    76. mQOgreRenderWindowList.append(orw4);
    77. QHBoxLayout* Layout4 = new QHBoxLayout();
    78. Layout4->addWidget(orw4);
    79. central4->setLayout(Layout4);
    80. ////////////////////////////////////////////
    81. QWidget *central5 = new QGroupBox("1,1", this);
    82. wi=central5->width();
    83. hi=central5->height();
    84. // QLabel* orw5 = new QLabel("i am4",central3);
    85. QOgreRenderWindow *orw5 = new QOgreRenderWindow(QString("View5"),mSceneMgr,mRoot,nb_cam,wi,hi);
    86. mQOgreRenderWindowList.append(orw5);
    87. QHBoxLayout* Layout5 = new QHBoxLayout();
    88. Layout5->addWidget(orw5);
    89. central5->setLayout(Layout5);
    90. /////////////////////////////////////////
    91. QWidget *central6 = new QGroupBox("1,2", this);
    92. wi=central6->width();
    93. hi=central6->height();
    94. //QLabel* orw3 = new QLabel("i am4",central3);
    95. QOgreRenderWindow *orw6 = new QOgreRenderWindow(QString("View6"),mSceneMgr,mRoot,nb_cam,wi,hi);
    96. mQOgreRenderWindowList.append(orw6);
    97. QHBoxLayout* Layout6 = new QHBoxLayout();
    98. Layout6->addWidget(orw6);
    99. central6->setLayout(Layout6);
    100. ////////////////////////////////////////////
    101. QWidget *central7 = new QGroupBox("2,0", this);
    102. wi=central7->width();
    103. hi=central7->height();
    104. //QLabel* orw = new QLabel("i am4",central7);
    105. QOgreRenderWindow *orw7 = new QOgreRenderWindow(QString("View7"),mSceneMgr,mRoot,nb_cam,wi,hi);
    106. mQOgreRenderWindowList.append(orw7);
    107. QHBoxLayout* Layout7 = new QHBoxLayout();
    108. Layout7->addWidget(orw7);
    109. central7->setLayout(Layout7);
    110. ////////////////////////////////////////////////////////////
    111. QWidget *central8 = new QGroupBox("2,1", this);
    112. wi=central8->width();
    113. hi=central8->height();
    114. // QLabel* orw3 = new QLabel("i am4",central8);
    115. QOgreRenderWindow *orw8 = new QOgreRenderWindow(QString("View8"),mSceneMgr,mRoot,nb_cam,wi,hi);
    116. mQOgreRenderWindowList.append(orw8);
    117. QHBoxLayout* Layout8 = new QHBoxLayout();
    118. Layout8->addWidget(orw8);
    119. central8->setLayout(Layout8);
    120. /////////////////////////////////////////////////////////////
    121. QWidget *central9 = new QGroupBox("2,2", this);
    122. wi=central9->width();
    123. hi=central9->height();
    124. // QLabel* orw3 = new QLabel("i am4",central9);
    125. QOgreRenderWindow *orw9 = new QOgreRenderWindow(QString("View9"),mSceneMgr,mRoot,nb_cam,wi,hi);
    126. mQOgreRenderWindowList.append(orw9);
    127. QHBoxLayout* Layout9 = new QHBoxLayout();
    128. Layout9->addWidget(orw9);
    129. central9->setLayout(Layout9);
    130. ///////////////////////////////////////////////
    131. QWidget *central10 = new QGroupBox("3,0", this);
    132. wi=central10->width();
    133. hi=central10->height();
    134. //QLabel* orw3 = new QLabel("i am4",central10);
    135. QOgreRenderWindow *orw10 = new QOgreRenderWindow(QString("View10"),mSceneMgr,mRoot,nb_cam,wi,hi);
    136. mQOgreRenderWindowList.append(orw10);
    137. QHBoxLayout* Layout10 = new QHBoxLayout();
    138. Layout10->addWidget(orw10);
    139. central10->setLayout(Layout10);
    140.  
    141. ////////////////////////////////////////////////////
    142. QWidget *central11 = new QGroupBox("3,1", this);
    143. wi=central11->width();
    144. hi=central11->height();
    145. // QLabel* orw3 = new QLabel("i am4",central11);
    146. QOgreRenderWindow *orw11 = new QOgreRenderWindow(QString("View111"),mSceneMgr,mRoot,nb_cam,wi,hi);
    147. mQOgreRenderWindowList.append(orw11);
    148. QHBoxLayout* Layout11 = new QHBoxLayout();
    149. Layout11->addWidget(orw11);
    150. central11->setLayout(Layout11);
    151. ///////////////////////////////
    152. QWidget *central12 = new QGroupBox("3,2", this);
    153. wi=central12->width();
    154. hi=central12->height();
    155. // QLabel* orw3 = new QLabel("i am4",central11);
    156. QOgreRenderWindow *orw12 = new QOgreRenderWindow(QString("View12"),mSceneMgr,mRoot,nb_cam,wi,hi);
    157. mQOgreRenderWindowList.append(orw12);
    158. QHBoxLayout* Layout12 = new QHBoxLayout();
    159. Layout12->addWidget(orw12);
    160. central12->setLayout(Layout12);
    161. ////////////////////////////////////////////////
    162. rightSide->addWidget(/*new QGroupBox("0,0"), 0, 0 */central1,0,0);
    163. rightSide->addWidget(central2,0,1);
    164. rightSide->addWidget(central3,0,2);
    165. rightSide->addWidget(central4, 1, 0 );
    166. rightSide->addWidget(central5, 1, 1 );
    167. rightSide->addWidget(central6, 1, 2 );
    168. rightSide->addWidget(central7, 2, 0 );
    169. rightSide->addWidget(central8, 2, 1 );
    170. rightSide->addWidget(central9, 2, 2 );
    171. rightSide->addWidget(central10, 3, 0 );
    172. rightSide->addWidget(central11, 3, 1 );
    173. rightSide->addWidget(central12, 3, 2 );
    174.  
    175.  
    176. mVerticalLayout->addWidget(central);
    177. mVerticalLayout->addLayout(rightSide);
    178.  
    179.  
    180. }
    181. for(int i = 0;i<mQOgreRenderWindowList.count();i++)
    182. {
    183. connect(mQOgreRenderWindowList[i],SIGNAL(keyPress(QKeyEvent*)),this,SLOT(keyPress(QKeyEvent*)));
    184. connect(mQOgreRenderWindowList[i],SIGNAL(keyRelease(QKeyEvent*)),this,SLOT(keyRelease(QKeyEvent*)));
    185. connect(mQOgreRenderWindowList[i],SIGNAL(mousePress(QMouseEvent*)),this,SLOT(mousePress(QMouseEvent*)));
    186. connect(mQOgreRenderWindowList[i],SIGNAL(mouseRelease(QMouseEvent*)),this,SLOT(mouseRelease(QMouseEvent*)));
    187. connect(mQOgreRenderWindowList[i],SIGNAL(mouseMove(QMouseEvent*)),this,SLOT(mouseMove(QMouseEvent*)));
    188. connect(mQOgreRenderWindowList[i],SIGNAL(wheel(QWheelEvent*)),this,SLOT(wheel(QWheelEvent*)));
    189. }
    190.  
    191. }
    To copy to clipboard, switch view to plain text mode 
    as you know that work
    Now i add this function "setCameraPosition" that work too (it add to me an object )
    The question or the problem now
    1-i want when i execute ""setCameraPosition"" i add than view
    is it possible ?
    that mean i
    i want in the start of the program i see only the left view (i execute only)
    Qt Code:
    1. QOgreRenderWindow *orw = new QOgreRenderWindow(QString("View0"),mSceneMgr,mRoot,nb_cam,wi,hi);
    To copy to clipboard, switch view to plain text mode 
    and in each time and when i execute "setCameraPosition" i apply
    Qt Code:
    1. QOgreRenderWindow *orw = new QOgreRenderWindow(QString("View0"),mSceneMgr,mRoot,nb_cam,wi,hi);
    To copy to clipboard, switch view to plain text mode 
    and put it in the layout

  2. #2
    Join Date
    Sep 2011
    Posts
    1,241
    Thanks
    3
    Thanked 127 Times in 126 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: update the view dynamically

    aren't you also dreamvig?

    and in each time and when i execute "setCameraPosition" i apply
    Qt Code:
    1. QOgreRenderWindow *orw = new QOgreRenderWindow(QString("View0"),mSceneMgr,mRoot,nb_cam,wi,hi);
    To copy to clipboard, switch view to plain text mode 
    and put it in the layout
    Ok, so make a slot, put that code in the slot. What are you waiting for?
    If you have a problem, CUT and PASTE your code. Do not retype or simplify it. Give a COMPLETE and COMPILABLE example of your problem. Otherwise we are all guessing the problem from a fabrication where relevant details are often missing.

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

    Default Re: update the view dynamically

    What i make as slot ? all this function ?

    void QOgreWidget::setViewNum(int num)

  4. #4
    Join Date
    Sep 2011
    Posts
    1,241
    Thanks
    3
    Thanked 127 Times in 126 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: update the view dynamically

    are you also dreamvig?
    If you have a problem, CUT and PASTE your code. Do not retype or simplify it. Give a COMPLETE and COMPILABLE example of your problem. Otherwise we are all guessing the problem from a fabrication where relevant details are often missing.

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

    Default Re: update the view dynamically

    yes , i explained to you why i have two account

  6. #6
    Join Date
    Sep 2011
    Posts
    1,241
    Thanks
    3
    Thanked 127 Times in 126 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: update the view dynamically

    What do you want to happen when you push the button?

    figure that out, and put it in a slot.
    If you have a problem, CUT and PASTE your code. Do not retype or simplify it. Give a COMPLETE and COMPILABLE example of your problem. Otherwise we are all guessing the problem from a fabrication where relevant details are often missing.

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

    Default Re: update the view dynamically

    yes
    it work thanks

  8. #8
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: update the view dynamically

    Quote Originally Posted by rimie23 View Post
    yes , i explained to you why i have two account
    Please explain it to me too, otherwise I'll have to delete one of your accounts.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


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

    Default Re: update the view dynamically

    Qt Code:
    1. Please explain it to me too, otherwise I'll have to delete one of your accounts.
    To copy to clipboard, switch view to plain text mode 
    OK , delete "dreamvig"
    i can make it but i found that there is problem
    that's the code
    in mainwindow
    Qt Code:
    1. connect(page_14, SIGNAL(coordinateChanged(const Ogre::Vector3&)),
    2. mQOgreWidget , SLOT(setCameraPosition(const Ogre::Vector3&)));
    To copy to clipboard, switch view to plain text mode 
    in "setCameraPosition"
    Qt Code:
    1. void QOgreWidget::setCameraPosition(const Ogre::Vector3 &pos)
    2. {
    3. central1 = new QGroupBox("Camera"+nbv, this);
    4. float wi1=central1->width();
    5. float hi1=central1->height();
    6. orw1 = new QOgreRenderWindow(QString("View"+nbv),mSceneMgr,mRoot,nb_cam,wi1,hi1, mNode,pos,nodeM);
    7. mQOgreRenderWindowList.append(orw1);
    8. nbv++;
    9.  
    10. Layout1 = new QHBoxLayout();
    11. Layout1->addWidget(orw1);
    12. central1->setLayout(Layout1);
    13.  
    14. rightSide->addWidget(central1,ligne,colon);
    15. colon++;
    16. if(colon==3)
    17. {
    18. colon=0;
    19. ligne++;
    20. }♣
    21. }
    To copy to clipboard, switch view to plain text mode 
    but when i run i look that the name of group box is
    if i execute 1 time "setCameraPosition" : amera
    the seconde one // : mera
    3 time: era
    4 time: ra
    5 :a
    and it make exeption when i want add the 6 th

    and that waht i see when idebug

    "View0", 3863365216x3863365216 windowed miscParams: externalWindowHandle=2688834
    21:56:01: GLRenderSystem::_createRenderWindow "iew", 3863365216x3863365216 windowed miscParams: externalWindowHandle=2032484
    21:56:03: GLRenderSystem::_createRenderWindow "ew", 3863365216x3863365216 windowed miscParams: externalWindowHandle=133000
    21:56:05: GLRenderSystem::_createRenderWindow "w", 3863365216x3863365216 windowed miscParams: externalWindowHandle=133004
    21:56:09: GLRenderSystem::_createRenderWindow "", 3863365216x3863365216 windowed miscParams: externalWindowHandle=198516
    21:56:11: OGRE EXCEPTION(2:InvalidParametersException): Window with name '' already exists in GLRenderSystem::_createRenderWindow at ..\..\..\..\..\RenderSystems\GL\src\OgreGLRenderSy stem.cpp (line 986)

    EDIT

    it work now thanks ror ameleto
    Qt Code:
    1. orw1 = new QOgreRenderWindow(QString ("View %0").arg(nbv)
    To copy to clipboard, switch view to plain text mode 
    Last edited by rimie23; 10th June 2012 at 22:27.

  10. #10
    Join Date
    Sep 2011
    Posts
    1,241
    Thanks
    3
    Thanked 127 Times in 126 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: update the view dynamically

    This,
    "Camera"+nbv

    probably doesnt do what you think - you are adding a number to a pointer.
    If you have a problem, CUT and PASTE your code. Do not retype or simplify it. Give a COMPLETE and COMPILABLE example of your problem. Otherwise we are all guessing the problem from a fabrication where relevant details are often missing.

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

    Default Re: update the view dynamically

    yes for that i change and i make like that
    (QString ("View %0").arg(nbv)
    that work

Similar Threads

  1. how to update a tree view model
    By chow in forum Qt Programming
    Replies: 8
    Last Post: 26th March 2009, 15:27
  2. QGraphics view update : Help needed
    By kiranraj in forum Qt Programming
    Replies: 3
    Last Post: 3rd July 2007, 12:54
  3. Replies: 9
    Last Post: 7th November 2006, 15:10
  4. Replies: 6
    Last Post: 20th April 2006, 10:23
  5. View update problem
    By prakash in forum Qt Programming
    Replies: 6
    Last Post: 17th March 2006, 10:13

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.