PDA

View Full Version : size of horizontal layout



maarvi
28th June 2011, 08:11
hello every one this is my code


myplot * p = new myplot(gao.structpayloadgraph,gao1.structpayloadgr aph, gao.structcol-2, "payload");

myplot * p1 = new myplot(gao.structsessiongraph,gao.structsessiongra ph ,gao.structcol-2, "session");

ui->horizontalLayout_3->addWidget(p);

ui->horizontalLayout_3->addWidget(p1);

its working fine my graph are shown side by size but the problem is that it is good for small graphs having 5 ,6 points but when i try to show some bigger graph the window(in which graph is shown) become extremely large the it didn't fit on screen so is there a way by which i can take the size of horizontal layout and then resize my p , p1 to fit in to that area something like that

thankss

Rachol
28th June 2011, 08:45
You should base your size calculations on the widget on which the horizontalLayout_3 is set.

maarvi
28th June 2011, 08:50
Sorry sir i didnt get you can you please explain a lil bit more

Rachol
28th June 2011, 09:08
Assuming that there is some piece of code written by you or qt designer:


QWidget w = new QWidget(this);
w.setLayout(horizontalLayout_3);

You can calculate the available area by getting size of the widget "w". Remember thought, that there can be some other widgets, margins or spacing set in that layout also.

Santosh Reddy
28th June 2011, 10:54
IMO calculating size on widgets, and adjusting the graphs my not be a good solution, as it will it is still restricted by the screen size, you should use QScrollArea.

I remember you had a problem using QScrollArea earlier, is it with same application? You need to add objects in this hierarchy

graph1 -> h_layout1 -> widget1 -> scroll area1 -> h_layout_main -> main widget
graph2 -> h_layout2 -> widget2 -> scroll area2 -> h_layout_main -> main widget

(add graph to layout, set layout on widget, set widget on a scroll area, add scroll area to layout, set layout on main widget)

or even this will work,
graph1 -> scroll area1 -> h_layout_main -> main widget
graph2 -> scroll area2 -> h_layout_main -> main widget

You can either use Qt Designer / code to achieve this.

Rachol
28th June 2011, 11:24
IMO calculating size on widgets, and adjusting the graphs my not be a good solution, as it will it is still restricted by the screen size, you should use QScrollArea.

Agree with that 100%, but The following quote explains exactly why I propsed that solution :)


I remember you had a problem using QScrollArea earlier, is it with same application?