Module: Qt::LayoutEach

Includes:
QtEnumerable
Included in:
BoxLayout, FormLayout, GridLayout, HBoxLayout, Layout, StackedLayout, VBoxLayout
Defined in:
lib/ruber/qt_sugar.rb

Overview

Module implementing the #each method used by all layout classes

Ideally, this method should be implemented in Layout and other classes should inherit it. However, since QtRuby doesn’t actually implements inheritance between it’s classes, that doesn’t happen.

The #each method is then defined in this module which is included in all layout classes

Instance Method Summary collapse

Instance Method Details

#each {|w| ... } ⇒ Qt::Layout, Enumerator

Iterates on all items in the layout

The iteration order is from top to bottom and from left to right. In case of widgets which span multiple rows or columns (in case of a @Qt::GridLayout@), the widgets will only be passed one time.

Yields:

  • (w)

    block to call for each widget in the layout

Yield Parameters:

  • w (Qt::Widget)

    each widget

Returns:

  • (Qt::Layout, Enumerator)

    if no block is given, returns an enumerator, otherwise returns self



648
649
650
651
652
653
654
655
# File 'lib/ruber/qt_sugar.rb', line 648

def each
  return to_enum unless block_given?
  count.times do |i| 
    it = item_at i
    yield it.widget || it.layout
  end
  self
end