[Kde-bindings] PlasmaScripting::Applet: Unresolved constructor

Richard Dale rdale at foton.es
Mon Nov 17 20:14:11 UTC 2008


On Monday 17 November 2008 14:28:37 David Palacio wrote:
> I need some custom widgets that Plasma does not provide for an applet I am
> developing. For that I use QGraphicsProxyWidget but I cannot set the
> PlasmaScripting::Applet applet as a parent for it.
I've fixed this in the kdebase trunk. You can also work round it for KDE 4.1.x 
by passing 'self.applet_script.applet' as the parent instead of just 'self'.


> Following is a piece of code that will reproduce the error. (I know this is
> not entirely correct but the result is exactly the same) (Does not work for
> 4.2)
> kdeapp #kapplication creator @ .irbrc
> require 'plasma_applet'
> o = Qt::Object.new #Dummy object to create a PlasmaScripting::Applet
> class << o
> def applet
> end
> end
> a = PlasmaScripting::Applet.new o
> p = Qt::GraphicsProxyWidget.new a
> ArgumentError: unresolved constructor call Qt::GraphicsProxyWidget
>
>         from /usr/lib/ruby/1.8/Qt/qtruby4.rb:2450:in `initialize'
>         from /usr/lib/ruby/1.8/Qt/qtruby4.rb:2450:in `call'
>         from /usr/lib/ruby/1.8/Qt/qtruby4.rb:2450:in `try_initialize'
>         from /usr/lib/ruby/1.8/Qt/qtruby4.rb:2449:in `catch'
>         from /usr/lib/ruby/1.8/Qt/qtruby4.rb:2449:in `try_initialize'
>         from (irb):9:in `new'
>         from (irb):9
>
>
> This works fine:
> p = Qt::GraphicsProxyWidget.new Qt::GraphicsItem.new
>
> PS. I get this in both 4.1 and trunk/
>
>
> P.P.S The actual applet:
>
> require 'plasma_applet'
>
> module PlasmaAppletHelloRuby
>
> class Main < PlasmaScripting::Applet
>
>   def initialize(parent, args = nil)
>     super
>   end
>
>   def init
>     resize(600, 400)
>     @proxy = Qt::GraphicsProxyWidget.new
>     STDERR.puts self.class.ancestors
>     @proxy.setParentItem self
>     @proxy.widget = main
>   end
>
>   def paintInterface(p, option, rect)
>     p.pen = Qt::Color.new 'steelblue'
>     p.scale 3, 3
>     p.draw_text Qt::RectF.new( rect ), 'Hello Ruby'
>   end
>
>   def constraintsEvent(constraints)
>   end
>
> end
>
> end
The applet works now apart from this line:

@proxy.widget = main

I wasn't sure what you were intending to do here.

-- Richard



More information about the Kde-bindings mailing list