You are not logged in.

Dear visitor, welcome to QtForum.org. If this is your first visit here, please read the Help. It explains in detail how this page works. To use all features of this page, you should consider registering. Please use the registration form, to register here or read more information about the registration process. If you are already registered, please login here.

21

Thursday, May 24th 2012, 2:30pm

Hi
i change the idea
because i see this software "vicon" it similar as what i want

now when i run my project my scene is rendred in all the window(central window)

to make it like the photi i have two idea and their problem if you can advice to me what is the appropriate idea
1- the first idea i can devise y window with ogre like the photo BUT when i separate i can't make the lines that mean i cant defrent betewwen the veiw AND i can't write the name of the viewport is there methode in qt to draw lines like that(like the picture)(line in blue and lines in white , the lines that represent the edge of each viewport ?

2-i less the central widget as it , and i add otheres scorelarea to render the scene with the camera in it , BUT her the problem is how i said in my program to render the scen inside the scroller area

22

Thursday, May 24th 2012, 5:18pm

1 - yes. Just use paintEvent and draw whatever you want.

2 - I don't understand.
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.

23

Thursday, May 24th 2012, 7:19pm

Quoted

Just use paintEvent and draw whatever you want

if i can it don not exist problem for me

But can you more explain to the idea of how i draw ?
for exemple
in my painevent to draw my scene i make like that

Source code

1
2
3
4
5
6
7
void OgreWidget::paintEvent(QPaintEvent *e)
{
	mRoot->_fireFrameStarted();
	mWindow->update();
		mRoot->_fireFrameEnded();
		e->accept();
}

and with this code

Source code

1
2
3
4
5
6
7
8
9
Ogre::Viewport* vp1 =  mWindow->addViewport( mCamera1); //default values, rendered in the whole window
vp1->setBackgroundColour(Ogre::ColourValue(0,0,0));
 // Alter the camera aspect ratio to match the viewport
mCamera1->setAspectRatio(Ogre::Real(vp1->getActualWidth()) / Ogre::Real(vp1->getActualHeight())); 

Ogre::Viewport* vp2 = mWindow->addViewport( mCamera2, 1 , 0.75, 0.75, 0.25, 0.25 ); //small viewport, rendered in the lower right corner of the window (the 0.75's define the position, the 0.25's define the size
// Set backgrounc color
vp2->setBackgroundColour( Ogre::ColourValue( 1, 0, 0 ) );
mCamera2->setAspectRatio( Ogre::Real(vp2->getActualWidth()) / Ogre::Real(vp2->getActualHeight())); //don't forget to set the aspect ratio of the second camera

i can create two viewport within the lines, within the name of the camera just like this picture(you can see an bject in the big window andn small object in the small window there is no edge between the viewport for that we can't defer betewwen the both viewport)
[img]http://www.qtforum.org/index.php?page=Attachment&attachmentID=2990&h=767c80bd5a8a2729defe42a90998afa3f7efe694[/img]
chahd09 has attached the following file:
  • picture.jpg (19.77 kB - 3 times downloaded - latest: May 25th 2012, 6:35pm)

24

Thursday, May 24th 2012, 7:56pm

Source code

1
2
3
4
5
6
7
8
9
10
11
void OgreWidget::paintEvent(QPaintEvent *e)
{
	mRoot->_fireFrameStarted();
	mWindow->update();
	mRoot->_fireFrameEnded();

	// now use QPainter to draw a rectangle.
	// The size of the rect should be rect() (or a little smaller)

	e->accept();
}
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.

25

Thursday, May 24th 2012, 7:57pm

you know, you could also just put your viewport widget inside a layout and add some margin, then there would be some space between different widgets.
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.

26

Thursday, May 24th 2012, 8:12pm

thatnks for this idea
you mean
i create in my mainwidow many layout ?
big one for all the scene and the otheres for the small viwport?

EDIT
d'ont forget the big view and the other viewport all in in one widget

when i make that

Source code

1
2
3
4
5
6
MainWindow::MainWindow()  
    {  
        this->setBaseSize(1500,1500);  
        my_calsseWidget = new my_classe(this);  
          
        setCentralWidget(my_calsseWidget);

i will see all the viewport (the big and the smallers )
is that mean i must use one layout (because all the viewport are in one widget)

This post has been edited 1 times, last edit by "chahd09" (May 24th 2012, 8:26pm)


27

Thursday, May 24th 2012, 10:17pm

Just look at spacers and layouts. One widget can only have one layout, but e.g. gridlayout can have sub-layouts.

I suggest you do some reading and experimenting.
http://qt-project.org/doc/qt-4.8/QGridLayout.html
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.

28

Friday, May 25th 2012, 6:12pm

"suggest you do some reading and experimenting.
http://qt-project.org/doc/qt-4.8/QGridLayout.html"
Ok i will read this but i have one question

"One widget can only have one layout, "
That mean i can't use the idea of layout ?and i can use in my case the "gridlayout"

29

Friday, May 25th 2012, 11:52pm

i know that i ask many questions
but i relly do not undertsand how with grid layout i can subdivide my widget like that

i read that with "grid layout" i use many widget not one widget

Please explain t me , or just tell me if the grid layout is the best choici or i can subdivide with it my widget

30

Saturday, May 26th 2012, 10:18am

use hboxlayout and qgridlayout


Source code

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
#include <QtGui/QApplication>
#include <QHBoxLayout>
#include <QGridLayout>
#include <QGroupBox>

int main(int argc, char *argv[])
{
    QApplication a(argc, argv);
    QWidget w;


    QHBoxLayout* mainlayout = new QHBoxLayout;

    QGridLayout* rightSide = new QGridLayout;

    rightSide->addWidget(new QGroupBox("0,0"), 0, 0 );
    rightSide->addWidget(new QGroupBox("0,1"), 0, 1 );
    rightSide->addWidget(new QGroupBox("0,2"), 0, 2 );
    rightSide->addWidget(new QGroupBox("1,0"), 1, 0 );
    rightSide->addWidget(new QGroupBox("1,1"), 1, 1 );
    rightSide->addWidget(new QGroupBox("1,2"), 1, 2 );
    rightSide->addWidget(new QGroupBox("2,0"), 2, 0 );
    rightSide->addWidget(new QGroupBox("2,1"), 2, 1 );
    rightSide->addWidget(new QGroupBox("2,2"), 2, 2 );

    mainlayout->addWidget(new QGroupBox("big frame"));
    mainlayout->addLayout(rightSide);

    w.setLayout(mainlayout);

    w.show();

    return a.exec();
}
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.

31

Saturday, May 26th 2012, 10:39pm

Thanks for the code
it create new project and itpast it it work good and i understand it
BUt i still can't use it in my application when i make like that

Source code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
my_calsseWidget = new OgreWidget(this);
    setCentralWidget(ogreWidget);
		 QHBoxLayout* mainlayout = new QHBoxLayout;

    QGridLayout* rightSide = new QGridLayout;

    rightSide->addWidget(new QGroupBox("0,0"), 0, 0 );
    rightSide->addWidget(new QGroupBox("0,1"), 0, 1 );
    rightSide->addWidget(new QGroupBox("0,2"), 0, 2 );
    rightSide->addWidget(new QGroupBox("1,0"), 1, 0 );
    rightSide->addWidget(new QGroupBox("1,1"), 1, 1 );
    rightSide->addWidget(new QGroupBox("1,2"), 1, 2 );
    rightSide->addWidget(new QGroupBox("2,0"), 2, 0 );
    rightSide->addWidget(new QGroupBox("2,1"), 2, 1 );
    rightSide->addWidget(new QGroupBox("2,2"), 2, 2 );
	rightSide->addWidget(new QGroupBox("3,0"), 3, 0 );
    rightSide->addWidget(new QGroupBox("3,1"), 3, 1 );
    rightSide->addWidget(new QGroupBox("3,2"), 3, 2 );
	
    mainlayout->addWidget(new QGroupBox("big frame"));
    mainlayout->addLayout(rightSide);

  my_calsseWidget.setLayout(mainlayout);

it do not accept "my_calsseWidget"

32

Sunday, May 27th 2012, 8:48am

Ok ,
i fix it and i can see the grid layout and qhboxlayout
like that

Source code

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
  ogreWidget = new OgreWidget(this);
    //setCentralWidget(ogreWidget);
	createModel();
	 //QWidget w;
	
   // createActionMenus();
	


	////////////////////////////////////////////////////
	 QHBoxLayout* mainlayout = new QHBoxLayout;

    QGridLayout* rightSide = new QGridLayout;

    rightSide->addWidget(new QGroupBox("0,0"), 0, 0 );
    rightSide->addWidget(new QGroupBox("0,1"), 0, 1 );
    rightSide->addWidget(new QGroupBox("0,2"), 0, 2 );
    rightSide->addWidget(new QGroupBox("1,0"), 1, 0 );
    rightSide->addWidget(new QGroupBox("1,1"), 1, 1 );
    rightSide->addWidget(new QGroupBox("1,2"), 1, 2 );
    rightSide->addWidget(new QGroupBox("2,0"), 2, 0 );
    rightSide->addWidget(new QGroupBox("2,1"), 2, 1 );
    rightSide->addWidget(new QGroupBox("2,2"), 2, 2 );
	rightSide->addWidget(new QGroupBox("3,0"), 3, 0 );
    rightSide->addWidget(new QGroupBox("3,1"), 3, 1 );
    rightSide->addWidget(new QGroupBox("3,2"), 3, 2 );
	

mainlayout->addWidget(ogreWidget);
    //mainlayout->addWidget(new QGroupBox("big frame"));
QWidget *central = new QGroupBox("My Scene", this);
central->setLayout(mainlayout);
setCentralWidget(central);

    mainlayout->addLayout(rightSide);


But look the result
[img]http://www.qtforum.org/index.php?page=Attachment&attachmentID=2992&h=3fbe45101de642e16106eb2b0685160ead769682[/img]

it make all the viewports in the big frame
chahd09 has attached the following file:
  • viewport.jpg (45.13 kB - 11 times downloaded - latest: Jun 14th 2012, 9:22pm)

33

Sunday, May 27th 2012, 8:53am

look, you think about it for yourself for a second.

all those small camera view ports can be made into their own widget and put where the small group boxes are.
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.

34

Sunday, May 27th 2012, 9:00am

"all those small camera view ports can be made into their own widget"
yes all this small viewport in the same widget i make like that to create them

Source code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
void OgreWidget::createViewports(void)
{
    mWindow->addViewport(mCamera, 0, 0, 0, 0.5, 1); // large left half viewport
   int columns = 3;
   int rows = 4;
   for(int y = 0; y < rows; y++)
      for(int x = 0; x < columns; x++)
      {
         mWindow->addViewport(mCamera, 
            x + y * columns + 1, // each viewport needs a unique zorder value
            0.5f + (0.5f / columns) * x, // left edge
            (1.0f / rows) * y, // top edge
            0.5f / columns,  // tile width
            1.0f / rows); // tile height
      }
}

Quoted

and put where the small group boxes are.

what you mean ?

35

Sunday, May 27th 2012, 10:27am

I don't have the patience to continue. sorry.
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.

36

Sunday, May 27th 2012, 8:39pm

Ok
thanks for your help

i will try to find the idea (i hope that i am in the right way)
when i find it i will put it here

Similar threads