Class: Qt::TreeWidget
Instance Method Summary collapse
-
#initialize(parent = Qt::Application.activeWindow) ⇒ TreeWidget
constructor
A new instance of TreeWidget.
-
#topLevelItems ⇒ Object
Yields each of the top level items (those without a parent).
Constructor Details
#initialize(parent = Qt::Application.activeWindow) ⇒ TreeWidget
Returns a new instance of TreeWidget.
302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 |
# File 'lib/cosmos/gui/qt.rb', line 302 def initialize(parent = Qt::Application.activeWindow) super(parent) # Create a sensible default handler for clicking the checkboxes # of a tree. If you check a node all the lower nodes get checked. # If you uncheck a node all the lower nodes get unchecked. # If you check a lower node all the parent nodes get checked. connect(SIGNAL('itemClicked(QTreeWidgetItem*, int)')) do |node, col| if node.checkState == Qt::Checked # Set all nodes below this to checked node.setCheckStateAll(Qt::Checked) # Set all the nodes above this to checked while node.parent node = node.parent node.setCheckState(0, Qt::Checked) end else # Set all nodes below this to unchecked node.setCheckStateAll(Qt::Unchecked) end end end |
Instance Method Details
#topLevelItems ⇒ Object
Yields each of the top level items (those without a parent).
327 328 329 330 331 |
# File 'lib/cosmos/gui/qt.rb', line 327 def topLevelItems topLevelItemCount.times do |index| yield topLevelItem(index) end end |