All pastes #144001 Raw Edit

tuxplorer

public text v1 · immutable
#144001 ·published 2006-08-22 09:09 UTC
rendered paste body
class Question_text_widget < Qt::Widget
        def initialize(name,label,parent,answer)
                super(parent)
                @name = name
                @hbox = Qt::HBox.new(self)
                @hbox.setGeometry( Qt::Rect.new(40, 0, 390, 30) )
                @hbox.setSpacing(10)
                @lbl = Qt::Label.new(@hbox,label)
                @lbl.setText(label)
                @txt = Qt::LineEdit.new(@hbox,name)
                @txt.setText(answer)
                @chk = Qt::CheckBox.new(@hbox)
                Qt::Object.connect(@chk, SIGNAL("stateChanged()"), @txt, SLOT("question_toggle()") )

        end
        def get_answer
                return @txt.text()
        end
        def get_name
                return @name
        end
        def question_toggle
                @txt.setDisabled(@txt.isEnabled)
                @txt.repaint
        end
end

a = Qt::Application.new(ARGV)
w = Question_text_widget.new("test","test",nil,"test")
a.mainWidget = w
w.show
a.exec