Class: MetaBuilder::Qt4MB::GenericDialog
- Inherits:
-
Qt::Dialog
- Object
- Qt::Dialog
- MetaBuilder::Qt4MB::GenericDialog
- Defined in:
- lib/MetaBuilder/Qt4/parameter.rb
Class Method Summary collapse
-
.get_type(parent, type, title, label, val, target) ⇒ Object
A convenience wrapper around the functionnality.
Instance Method Summary collapse
- #exec ⇒ Object
-
#initialize(parent, type, title, label, val, target) ⇒ GenericDialog
constructor
Creates a generic input dialog for the type type.
Constructor Details
#initialize(parent, type, title, label, val, target) ⇒ GenericDialog
Creates a generic input dialog for the type type.
125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 |
# File 'lib/MetaBuilder/Qt4/parameter.rb', line 125 def initialize(parent, type, title, label, val, target) super(parent) self.window_title = title vbox = Qt::VBoxLayout.new(self) hbox = Qt::HBoxLayout.new @label = Qt::Label.new(label) hbox.(@label) @widget = type.(nil, target) hbox.(@widget) @widget.value = val vbox.add_layout(hbox) hbox = Qt::HBoxLayout.new # OK and Cancel buttons = Qt::PushButton.new("OK") connect(, SIGNAL('clicked()'), SLOT('accept()')) hbox.() = Qt::PushButton.new("Cancel") connect(, SIGNAL('clicked()'), SLOT('reject()')) hbox.() vbox.add_layout(hbox) # and that's all ! end |
Class Method Details
.get_type(parent, type, title, label, val, target) ⇒ Object
A convenience wrapper around the functionnality. Creates a GenericDialog and executes it.
163 164 165 166 |
# File 'lib/MetaBuilder/Qt4/parameter.rb', line 163 def self.get_type(parent, type, title, label, val, target) dialog = new(parent, type, title, label, val, target) return dialog.exec end |
Instance Method Details
#exec ⇒ Object
152 153 154 155 156 157 158 159 |
# File 'lib/MetaBuilder/Qt4/parameter.rb', line 152 def exec res = super if res > 0 return @widget.value else raise CancelInput, "User cancelled input" end end |