Development/Tutorials/Qt4 Ruby Tutorial/Chapter 04

From KDE TechBase
Revision as of 17:03, 28 December 2009 by Alisha (talk | contribs) (Created page with '{{Template:I18n/Language Navigation Bar|Development/Tutorials/Qt4 Ruby Tutorial/Chapter 4}} {{TutorialBrowser| series=[[Development/Tutorials/Qt4_Ruby_Tutorial|Qt4 Ruby Tutoria...')
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.


Development/Tutorials/Qt4 Ruby Tutorial/Chapter 4


Let There Be Widgets
Tutorial Series   Qt4 Ruby Tutorial
Previous   Tutorial 3 - Family Values
What's Next   Tutorial 5 - Building Blocks
Further Reading   n/a

Let There Be Widgets

Files:

Overview

This example shows how to create your own widget, and describes how to control the minimum and maximum sizes of a widget.

require 'Qt4'

class MyWidget < Qt::Widget

 def initialize(parent = nil)
   super
   setFixedSize(200, 120)
   quit = Qt::PushButton.new(tr('Quit'), self)
   quit.setGeometry(62, 40, 75, 30)
   quit.setFont(Qt::Font.new('Times', 18, Qt::Font::Bold))
   connect(quit, SIGNAL('clicked()'), $qApp, SLOT('quit()'))
 end

end

app = Qt::Application.new(ARGV)

widget = MyWidget.new() widget.show()

app.exec()

Line by Line Walkthrough