diff options
Diffstat (limited to 'doc/html/layout.html')
-rw-r--r-- | doc/html/layout.html | 86 |
1 files changed, 43 insertions, 43 deletions
diff --git a/doc/html/layout.html b/doc/html/layout.html index 749cd3c45..7fd76c805 100644 --- a/doc/html/layout.html +++ b/doc/html/layout.html @@ -59,18 +59,18 @@ layouts and which generates the C++ layout code for you. <p> <h2> Layout Widgets </h2> <a name="1"></a><p> The easiest way to give your widgets a good layout is to use the -layout widgets: <a href="qhbox.html">TQHBox</a>, <a href="qvbox.html">TQVBox</a> and <a href="qgrid.html">TQGrid</a>. A layout widget +layout widgets: <a href="ntqhbox.html">TQHBox</a>, <a href="ntqvbox.html">TQVBox</a> and <a href="ntqgrid.html">TQGrid</a>. A layout widget automatically lays out its child widgets in the order they are constructed. To create more complex layouts, you can nest layout -widgets inside each other. (Note that <a href="qwidget.html">TQWidget</a> does not have a +widgets inside each other. (Note that <a href="ntqwidget.html">TQWidget</a> does not have a layout by default, you must add one if you want to lay out widgets -inside a <a href="qwidget.html">TQWidget</a>.) +inside a <a href="ntqwidget.html">TQWidget</a>.) <p> <ul> -<li> A <a href="qhbox.html">TQHBox</a> lays out its child widgets in a horizontal row, left to right. +<li> A <a href="ntqhbox.html">TQHBox</a> lays out its child widgets in a horizontal row, left to right. <p> <center><img src="qhbox-m.png" alt="Horizontal box with five child widgets"></center> -<p> <li> A <a href="qvbox.html">TQVBox</a> lays out its child widgets in a vertical column, top to bottom. +<p> <li> A <a href="ntqvbox.html">TQVBox</a> lays out its child widgets in a vertical column, top to bottom. <p> <center><img src="qvbox-m.png" alt="Vertical box with five child widgets"></center> -<p> <li> A <a href="qgrid.html">TQGrid</a> lays out its child widgets in a two dimensional grid. +<p> <li> A <a href="ntqgrid.html">TQGrid</a> lays out its child widgets in a two dimensional grid. You can specify how many columns the grid has, and it is populated left to right, beginning a new row when the previous row is full. The grid is fixed; the child widgets will not flow to other rows as the widget is @@ -79,22 +79,22 @@ resized. <p> <center><img src="qgrid-m.png" alt="Two-column grid with five child widgets"></center> <p> The grid shown above can be produced by the following code: <pre> - <a href="qgrid.html">TQGrid</a> *mainGrid = new <a href="qgrid.html">TQGrid</a>( 2 ); // a 2 x n grid - new <a href="qlabel.html">TQLabel</a>( "One", mainGrid ); - new <a href="qlabel.html">TQLabel</a>( "Two", mainGrid ); - new <a href="qlabel.html">TQLabel</a>( "Three", mainGrid ); - new <a href="qlabel.html">TQLabel</a>( "Four", mainGrid ); - new <a href="qlabel.html">TQLabel</a>( "Five", mainGrid ); + <a href="ntqgrid.html">TQGrid</a> *mainGrid = new <a href="ntqgrid.html">TQGrid</a>( 2 ); // a 2 x n grid + new <a href="ntqlabel.html">TQLabel</a>( "One", mainGrid ); + new <a href="ntqlabel.html">TQLabel</a>( "Two", mainGrid ); + new <a href="ntqlabel.html">TQLabel</a>( "Three", mainGrid ); + new <a href="ntqlabel.html">TQLabel</a>( "Four", mainGrid ); + new <a href="ntqlabel.html">TQLabel</a>( "Five", mainGrid ); </pre> <p> You can adjust the layout to some extent by calling -<a href="qwidget.html#setMinimumSize">TQWidget::setMinimumSize</a>() or <a href="qwidget.html#setFixedSize">TQWidget::setFixedSize</a>() on the child widgets. +<a href="ntqwidget.html#setMinimumSize">TQWidget::setMinimumSize</a>() or <a href="ntqwidget.html#setFixedSize">TQWidget::setFixedSize</a>() on the child widgets. <p> <h2> Adding Widgets to a Layout </h2> <a name="2"></a><p> When you add widgets to a layout the layout process works as follows: <ol type=1> <li> All the widgets will initially be allocated an amount of space in -accordance with their <a href="qwidget.html#sizePolicy">TQWidget::sizePolicy</a>(). +accordance with their <a href="ntqwidget.html#sizePolicy">TQWidget::sizePolicy</a>(). <li> If any of the widgets have stretch factors set, with a value greater than zero, then they are allocated space in proportion to their <a href="#stretch">stretch factor</a>. @@ -117,18 +117,18 @@ determining factor.) </h3> <a name="2-1"></a><p> Widgets are normally created without any stretch factor set. When they are laid out in a layout the widgets are given a share of space in -accordance with their <a href="qwidget.html#sizePolicy">TQWidget::sizePolicy</a>() or their minimum size hint +accordance with their <a href="ntqwidget.html#sizePolicy">TQWidget::sizePolicy</a>() or their minimum size hint whichever is the greater. Stretch factors are used to change how much space widgets are given in proportion to one another. -<p> If we have three widgets laid out using a <a href="qhbox.html">TQHBox</a> with no stretch +<p> If we have three widgets laid out using a <a href="ntqhbox.html">TQHBox</a> with no stretch factors set we will get a layout like this: <p> <center><img src="layout1.png" alt="3 widgets in a row"></center> <p> If we apply stretch factors to each widget, they will be laid out in proportion (but never less than their minimum size hint), e.g. <p> <center><img src="layout2.png" alt="3 stretch factored widgets in a row"></center> -<p> <h2> <a href="qlayout.html">TQLayout</a> subclassing +<p> <h2> <a href="ntqlayout.html">TQLayout</a> subclassing </h2> -<a name="3"></a><p> If you need more control over the layout, use a <a href="qlayout.html">TQLayout</a> subclass. The layout classes included in TQt are <a href="qgridlayout.html">TQGridLayout</a> and <a href="qboxlayout.html">TQBoxLayout</a>. (<a href="qhboxlayout.html">TQHBoxLayout</a> and <a href="qvboxlayout.html">TQVBoxLayout</a> are trivial subclasses of <a href="qboxlayout.html">TQBoxLayout</a>, +<a name="3"></a><p> If you need more control over the layout, use a <a href="ntqlayout.html">TQLayout</a> subclass. The layout classes included in TQt are <a href="qgridlayout.html">TQGridLayout</a> and <a href="qboxlayout.html">TQBoxLayout</a>. (<a href="qhboxlayout.html">TQHBoxLayout</a> and <a href="qvboxlayout.html">TQVBoxLayout</a> are trivial subclasses of <a href="qboxlayout.html">TQBoxLayout</a>, that are simpler to use and make the code easier to read.) <p> When you use a layout, you must insert each child both into its parent widget (done in the constructor) and into its layout (typically done @@ -138,20 +138,20 @@ stretch, and placement. <p> The following code makes a grid like the one above, with a couple of improvements: <pre> - <a href="qwidget.html">TQWidget</a> *main = new <a href="qwidget.html">TQWidget</a>; + <a href="ntqwidget.html">TQWidget</a> *main = new <a href="ntqwidget.html">TQWidget</a>; // make a 1x1 grid; it will auto-expand <a href="qgridlayout.html">TQGridLayout</a> *grid = new <a href="qgridlayout.html">TQGridLayout</a>( main, 1, 1 ); // add the first four widgets with (row, column) addressing - grid-><a href="qgridlayout.html#addWidget">addWidget</a>( new <a href="qlabel.html">TQLabel</a>( "One", main ), 0, 0 ); - grid-><a href="qgridlayout.html#addWidget">addWidget</a>( new <a href="qlabel.html">TQLabel</a>( "Two", main ), 0, 1 ); - grid-><a href="qgridlayout.html#addWidget">addWidget</a>( new <a href="qlabel.html">TQLabel</a>( "Three", main ), 1, 0 ); - grid-><a href="qgridlayout.html#addWidget">addWidget</a>( new <a href="qlabel.html">TQLabel</a>( "Four", main ), 1, 1 ); + grid-><a href="qgridlayout.html#addWidget">addWidget</a>( new <a href="ntqlabel.html">TQLabel</a>( "One", main ), 0, 0 ); + grid-><a href="qgridlayout.html#addWidget">addWidget</a>( new <a href="ntqlabel.html">TQLabel</a>( "Two", main ), 0, 1 ); + grid-><a href="qgridlayout.html#addWidget">addWidget</a>( new <a href="ntqlabel.html">TQLabel</a>( "Three", main ), 1, 0 ); + grid-><a href="qgridlayout.html#addWidget">addWidget</a>( new <a href="ntqlabel.html">TQLabel</a>( "Four", main ), 1, 1 ); // add the last widget on row 2, spanning from column 0 to // column 1, and center aligned - grid-><a href="qgridlayout.html#addMultiCellWidget">addMultiCellWidget</a>( new <a href="qlabel.html">TQLabel</a>( "Five", main ), 2, 2, 0, 1, + grid-><a href="qgridlayout.html#addMultiCellWidget">addMultiCellWidget</a>( new <a href="ntqlabel.html">TQLabel</a>( "Five", main ), 2, 2, 0, 1, TQt::AlignCenter ); // let the ratio between the widths of columns 0 and 1 be 2:3 @@ -162,11 +162,11 @@ improvements: <p> You can insert layouts inside a layout by giving the parent layout as a parameter in the constructor. <pre> - <a href="qwidget.html">TQWidget</a> *main = new <a href="qwidget.html">TQWidget</a>; - <a href="qlineedit.html">TQLineEdit</a> *field = new <a href="qlineedit.html">TQLineEdit</a>( main ); - <a href="qpushbutton.html">TQPushButton</a> *ok = new <a href="qpushbutton.html">TQPushButton</a>( "OK", main ); - <a href="qpushbutton.html">TQPushButton</a> *cancel = new <a href="qpushbutton.html">TQPushButton</a>( "Cancel", main ); - <a href="qlabel.html">TQLabel</a> *label = new <a href="qlabel.html">TQLabel</a>( "Write once, compile everywhere.", main ); + <a href="ntqwidget.html">TQWidget</a> *main = new <a href="ntqwidget.html">TQWidget</a>; + <a href="ntqlineedit.html">TQLineEdit</a> *field = new <a href="ntqlineedit.html">TQLineEdit</a>( main ); + <a href="ntqpushbutton.html">TQPushButton</a> *ok = new <a href="ntqpushbutton.html">TQPushButton</a>( "OK", main ); + <a href="ntqpushbutton.html">TQPushButton</a> *cancel = new <a href="ntqpushbutton.html">TQPushButton</a>( "Cancel", main ); + <a href="ntqlabel.html">TQLabel</a> *label = new <a href="ntqlabel.html">TQLabel</a>( "Write once, compile everywhere.", main ); // a layout on a widget <a href="qvboxlayout.html">TQVBoxLayout</a> *vbox = new <a href="qvboxlayout.html">TQVBoxLayout</a>( main ); @@ -186,7 +186,7 @@ into. <p> <h2> Custom Layouts </h2> <a name="4"></a><p> If the built-in layout classes are not sufficient, you can define your -own. You must make a subclass of <a href="qlayout.html">TQLayout</a> that handles resizing and +own. You must make a subclass of <a href="ntqlayout.html">TQLayout</a> that handles resizing and size calculations, as well as a subclass of <a href="qglayoutiterator.html">TQGLayoutIterator</a> to iterate over your layout class. <p> See the <a href="customlayout.html">Custom Layout</a> page for an @@ -194,24 +194,24 @@ in-depth description. <p> <h2> Custom Widgets In Layouts </h2> <a name="5"></a><p> When you make your own widget class, you should also communicate its -layout properties. If the widget has a <a href="qlayout.html">TQLayout</a>, this is already taken +layout properties. If the widget has a <a href="ntqlayout.html">TQLayout</a>, this is already taken care of. If the widget does not have any child widgets, or uses manual -layout, you should reimplement the following <a href="qwidget.html">TQWidget</a> member functions: +layout, you should reimplement the following <a href="ntqwidget.html">TQWidget</a> member functions: <p> <ul> -<li> <a href="qwidget.html#sizeHint">TQWidget::sizeHint</a>() returns the preferred size of the widget. -<li> <a href="qwidget.html#minimumSizeHint">TQWidget::minimumSizeHint</a>() returns the smallest size the widget can have. -<li> <a href="qwidget.html#sizePolicy">TQWidget::sizePolicy</a>() returns a <a href="qsizepolicy.html">TQSizePolicy</a>; a value describing +<li> <a href="ntqwidget.html#sizeHint">TQWidget::sizeHint</a>() returns the preferred size of the widget. +<li> <a href="ntqwidget.html#minimumSizeHint">TQWidget::minimumSizeHint</a>() returns the smallest size the widget can have. +<li> <a href="ntqwidget.html#sizePolicy">TQWidget::sizePolicy</a>() returns a <a href="ntqsizepolicy.html">TQSizePolicy</a>; a value describing the space requirements of the widget. </ul> -<p> Call <a href="qwidget.html#updateGeometry">TQWidget::updateGeometry</a>() whenever the size hint, minimum size +<p> Call <a href="ntqwidget.html#updateGeometry">TQWidget::updateGeometry</a>() whenever the size hint, minimum size hint or size policy changes. This will cause a layout recalculation. Multiple calls to updateGeometry() will only cause one recalculation. <p> If the preferred height of your widget depends on its actual width -(e.g. a label with automatic word-breaking), set the <a href="qsizepolicy.html#hasHeightForWidth">hasHeightForWidth</a>() flag in -<a href="qwidget.html#sizePolicy">sizePolicy</a>(), and reimplement <a href="qwidget.html#heightForWidth">TQWidget::heightForWidth</a>(). +(e.g. a label with automatic word-breaking), set the <a href="ntqsizepolicy.html#hasHeightForWidth">hasHeightForWidth</a>() flag in +<a href="ntqwidget.html#sizePolicy">sizePolicy</a>(), and reimplement <a href="ntqwidget.html#heightForWidth">TQWidget::heightForWidth</a>(). <p> Even if you implement heightForWidth(), it is still necessary to provide a good sizeHint(). The sizeHint() provides the preferred width -of the widget, and it is used by <a href="qlayout.html">TQLayout</a> subclasses that do not +of the widget, and it is used by <a href="ntqlayout.html">TQLayout</a> subclasses that do not support heightForWidth() (both <a href="qgridlayout.html">TQGridLayout</a> and <a href="qboxlayout.html">TQBoxLayout</a> support it). <p> For further guidance when implementing these functions, see their implementations in existing TQt classes that have similar layout @@ -219,11 +219,11 @@ requirements to your new widget. <p> <h2> Manual Layout </h2> <a name="6"></a><p> If you are making a one-of-a-kind special layout, you can also make a -custom widget as described above. Reimplement <a href="qwidget.html#resizeEvent">TQWidget::resizeEvent</a>() -to calculate the required distribution of sizes and call <a href="qwidget.html#setGeometry">setGeometry</a>() on each child. -<p> The widget will get an event with <a href="qevent.html#type">type</a> +custom widget as described above. Reimplement <a href="ntqwidget.html#resizeEvent">TQWidget::resizeEvent</a>() +to calculate the required distribution of sizes and call <a href="ntqwidget.html#setGeometry">setGeometry</a>() on each child. +<p> The widget will get an event with <a href="ntqevent.html#type">type</a> <tt>LayoutHint</tt> when the layout needs to be recalculated. Reimplement -<a href="qwidget.html#event">TQWidget::event</a>() to be notified of <tt>LayoutHint</tt> events. +<a href="ntqwidget.html#event">TQWidget::event</a>() to be notified of <tt>LayoutHint</tt> events. <p> <h2> Layout Issues </h2> <a name="7"></a><p> The use of rich text in a label widget can introduce some problems to |