:github_url: hide .. _class_GridContainer: GridContainer ============= **繼承:** :ref:`Container` **<** :ref:`Control` **<** :ref:`CanvasItem` **<** :ref:`Node` **<** :ref:`Object` 將子控制項按照網格佈局排列的容器。 .. rst-class:: classref-introduction-group 說明 ---- **GridContainer** 會將其子控制項按照網格佈局排列。網格的列數由 :ref:`columns` 屬性指定,行數取決於容器中子控制項的數量。將保留每個大小的容器的列和行。 \ **注意:**\ **GridContainer** 只對繼承自 :ref:`Control` 的子節點生效。它不會重新排列繼承自 :ref:`Node2D` 的子節點。 .. rst-class:: classref-introduction-group 教學 ---- - :doc:`使用容器 <../tutorials/ui/gui_containers>` - `Operating System Testing Demo `__ .. rst-class:: classref-reftable-group 屬性 ---- .. table:: :widths: auto +-----------------------+------------------------------------------------------+-------+ | :ref:`int` | :ref:`columns` | ``1`` | +-----------------------+------------------------------------------------------+-------+ .. rst-class:: classref-reftable-group 主題屬性 -------- .. table:: :widths: auto +-----------------------+----------------------------------------------------------------------+-------+ | :ref:`int` | :ref:`h_separation` | ``4`` | +-----------------------+----------------------------------------------------------------------+-------+ | :ref:`int` | :ref:`v_separation` | ``4`` | +-----------------------+----------------------------------------------------------------------+-------+ .. rst-class:: classref-section-separator ---- .. rst-class:: classref-descriptions-group 屬性說明 -------- .. _class_GridContainer_property_columns: .. rst-class:: classref-property :ref:`int` **columns** = ``1`` :ref:`🔗` .. rst-class:: classref-property-setget - |void| **set_columns**\ (\ value\: :ref:`int`\ ) - :ref:`int` **get_columns**\ (\ ) **GridContainer** 中的列數。修改後,\ **GridContainer** 會重新排列其衍生自 Control 的子節點,以適應新的佈局。 .. rst-class:: classref-section-separator ---- .. rst-class:: classref-descriptions-group 主題屬性說明 ------------ .. _class_GridContainer_theme_constant_h_separation: .. rst-class:: classref-themeproperty :ref:`int` **h_separation** = ``4`` :ref:`🔗` The horizontal separation of child nodes. .. rst-class:: classref-item-separator ---- .. _class_GridContainer_theme_constant_v_separation: .. rst-class:: classref-themeproperty :ref:`int` **v_separation** = ``4`` :ref:`🔗` The vertical separation of child nodes. .. |virtual| replace:: :abbr:`virtual (本方法通常需要使用者覆寫才能生效。)` .. |required| replace:: :abbr:`required (This method is required to be overridden when extending its base class.)` .. |const| replace:: :abbr:`const (本方法沒有副作用。不會修改該實例的任何成員變數。)` .. |vararg| replace:: :abbr:`vararg (本方法除了這裡描述的參數外,還可以接受任意數量的參數。)` .. |constructor| replace:: :abbr:`constructor (本方法用於建構一個型別。)` .. |static| replace:: :abbr:`static (本方法無需實例即可呼叫,因此可以直接使用類別名稱呼叫。)` .. |operator| replace:: :abbr:`operator (本方法描述將本型別作為左運算元時可用的有效運算子。)` .. |bitfield| replace:: :abbr:`BitField (此值是由下列旗標組成的位元遮罩整數。)` .. |void| replace:: :abbr:`void (無回傳值。)`