Window 下Ruby 调用 Qt Webkit

 环境配置:

 

1. 安装 ruby 1.9.3-P194

2. 安装 qtbindings

    gem install qtbindings

 

测试程序:

webkit.rb

require 'Qt'
require 'qtwebkit'
app=Qt::Application.new(ARGV)
web=Qt::WebView.new
web.load Qt::Url.new('www.google.com.hk')
web.resize 1024,640
web.show
app.exec

 

 运行:

ruby webkit.rb

 

直接用html:

require 'qt'
require 'qtwebkit'

HTML=<<Eof
<html>
<head>
  <link href="http://twitter.github.com/bootstrap/assets/css/bootstrap.css" rel="stylesheet">
</head>
  <div class="container">
  <form>
  <fieldset>
    <legend>Legend</legend>
    <label>Label name</label>
    <input type="text" placeholder="Type something…">
    <span class="help-block">Example block-level help text here.</span>
    <label class="checkbox">
      <input type="checkbox"> Check me out
    </label>
    <button type="submit" class="btn">Submit</button>
  </fieldset>
</form>
<div>
</html>
Eof

app = Qt::Application.new(ARGV)
web = Qt::WebView.new
web.resize 1024,768
web.set_html HTML
web.show
app.exec

 

 

你可能感兴趣的:(Ruby,webkit,qt)