Các hành động thực hiện khi một widget KContainerLayout thay đổi kích cỡ phụ thuộc vào các vật dụng đã được thêm vào. Những người được thêm vào lúc bắt đầu sẽ vẫn chống lại các cạnh bắt đầu (đầu hoặc bên trái), và những người được thêm vào ở cuối sẽ ở lại chống lại cạnh cuối cùng (dưới hoặc bên phải) | Chapter 3 Laying Out Widgets in a Window 53 Packing widgets from the end has the same effect as packing them from the start except each widget is placed in the next available location starting at the bottom. The first button added to the bottom is the one created on lines 25 through 27 and added by the call to packEnd on line 28. The button created and added on lines 30 through 33 takes the position directly on top of the other button packed from the bottom and the one on lines 35 through 38 takes up a position directly above the other two at the bottom. Note The actions taken when a KContainerLayout widget is resized depends on how the widgets were added. Those added at the start will remain against the start edge top or left and those added at the end will stay against the end edge bottom or right . To orient the packed layout horizontally either remove the statement on line 8 because horizontal is the default or replace it with the following layout- setOrientation KContainerLayout Horizontal When the layout orientation is horizontal the packStart method inserts widgets on the left and the packEnd method inserts them on the right. The result is shown in Figure 3-13. container X I startONE I I startTWO I I startTHREE I I endTHREE I endTWO I I endONE I Figure 3-13 A KContainerLayout organizing widgets horizontally ISa Instead of HASa All of the previous examples in this chapter were widgets that internally created a layout manager of some sort. However because KContainerLayout is also a widget it can be extended instead of simply used. That is the widget no longer has a layout object it is a layout object. The following is an example of creating a widget that is capable of containing other widgets. Main 1 2 include 3 include 4 5 int main int argc char argv 6 7 KApplication app argc argv iscontainer 8 IsContainer iscontainer new IsContainer 54 Part I Getting Started 9 iscontainer- show 10 iscontainer 11 return